-
Notifications
You must be signed in to change notification settings - Fork 308
feat: update search on feeds table #3018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,6 +124,7 @@ const ResolvedPublishersCard = ({ | |
| } | ||
| } | ||
| }, | ||
| (items) => items, | ||
| { defaultSort: "ranking" }, | ||
| ); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,8 +14,9 @@ import { useCallback, useMemo } from "react"; | |
|
|
||
| export const useQueryParamFilterPagination = <T>( | ||
| items: T[], | ||
| predicate: (item: T, term: string) => boolean, | ||
| predicate: (item: T, search: string) => boolean, | ||
| doSort: (a: T, b: T, descriptor: SortDescriptor) => number, | ||
| doMutate: (items: T[], search: string) => T[], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could probably have deleted
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fair and I think at some point we can remove that. I didn't want to do a big refactor this time as it's used in a few places. |
||
| options?: { | ||
| defaultPageSize?: number | undefined; | ||
| defaultSort?: string | undefined; | ||
|
|
@@ -100,9 +101,13 @@ export const useQueryParamFilterPagination = <T>( | |
| [filteredItems, sortDescriptor, doSort], | ||
| ); | ||
|
|
||
| const mutatedItems = useMemo(() => { | ||
| return doMutate(sortedItems, search); | ||
| }, [doMutate, sortedItems, search]); | ||
|
|
||
| const paginatedItems = useMemo( | ||
| () => sortedItems.slice((page - 1) * pageSize, page * pageSize), | ||
| [page, pageSize, sortedItems], | ||
| () => mutatedItems.slice((page - 1) * pageSize, page * pageSize), | ||
| [page, pageSize, mutatedItems], | ||
| ); | ||
|
|
||
| const numPages = useMemo( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any chance this call would be blocking? Perhaps the array is small enough that this isn't a problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a few thousands items so I don't think it's going to impact too much