-
Notifications
You must be signed in to change notification settings - Fork 13
fix: LaunchDevly: Pagination for 'Only show flags with overrides' #426
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 |
|---|---|---|
|
|
@@ -53,12 +53,24 @@ function Flags({ | |
| const filteredFlags = useMemo(() => { | ||
| if (!flags) return []; | ||
| const flagEntries = Object.entries(flags); | ||
| const search = searchTerm.toLowerCase(); | ||
| const filtered = fuzzysort | ||
| .go(search, flagEntries, { all: true, key: '0', threshold: 0.7 }) | ||
| .map((result) => result.obj); | ||
| return filtered; | ||
| }, [flags, searchTerm]); | ||
| return flagEntries | ||
| .filter((entry) => { | ||
| if (!searchTerm) return true; | ||
| const [flagKey] = entry; | ||
| const result = fuzzysort.single(searchTerm.toLowerCase(), flagKey); | ||
| return result && result.score > -5000; // Adjust threshold as needed | ||
| }) | ||
| .filter((entry) => { | ||
| const [flagKey] = entry; | ||
| const hasOverride = flagKey in overrides; | ||
|
|
||
| if (onlyShowOverrides && !hasOverride) { | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| }); | ||
| }, [flags, searchTerm, onlyShowOverrides]); | ||
|
|
||
| const paginatedFlags = useMemo(() => { | ||
| const startIndex = currentPage * flagsPerPage; // Adjust startIndex calculation | ||
|
|
@@ -231,6 +243,7 @@ function Flags({ | |
| setSearchTerm(e.target.value); | ||
| setCurrentPage(0); // Reset pagination | ||
| }} | ||
| value={searchTerm} | ||
|
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. Previously the input of the search box wasn't actually coupled to the display of the search... We were just relying on onChange events. |
||
| aria-label="Search flags input" | ||
| /> | ||
| <IconButton | ||
|
|
@@ -249,10 +262,6 @@ function Flags({ | |
| const hasOverride = flagKey in overrides; | ||
| const currentValue = hasOverride ? overrideValue : flagValue; | ||
|
|
||
| if (onlyShowOverrides && !hasOverride) { | ||
|
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. This was causing issues, because we need to not do any filter logic in the display logic for the pagination to work as expected. |
||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <li | ||
| key={flagKey} | ||
|
|
||
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.
Refactored to be clearer filter entries. I assume we'll add another for tags in the future ;)