Skip to content

Commit

Permalink
fix order bug
Browse files Browse the repository at this point in the history
  • Loading branch information
HuskyHsu committed Jun 21, 2024
1 parent eb05df8 commit 5bfb327
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/pages/Pokedex/UseFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ export function UseFilter() {
onlyEvolution: searchParams.get('onlyEvolution') || '',
};

const newCacheObj = Object.fromEntries(
Object.entries(filter)
.filter(([_, value]) => value !== '' && value !== 1)
.filter(([_, value]) => (typeof value === 'object' ? value.size > 0 : true))
.map(([key, value]) => [key, typeof value === 'object' ? [...value].join('-') : value])
);

localStorage.setItem(localStorageKey, JSON.stringify(newCacheObj));

const updateState = (key: ValueKeys<Filter, string>[keyof Filter]) => {
return (val: string) => {
if (val === '') {
Expand Down

0 comments on commit 5bfb327

Please sign in to comment.