From 5bfb327f81aa1c32f6eb68bb142712842ec0bd06 Mon Sep 17 00:00:00 2001 From: HuskyHsu Date: Fri, 21 Jun 2024 15:46:49 +0800 Subject: [PATCH] fix order bug --- src/pages/Pokedex/UseFilter.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pages/Pokedex/UseFilter.ts b/src/pages/Pokedex/UseFilter.ts index 0d1db9d..5a89d2a 100644 --- a/src/pages/Pokedex/UseFilter.ts +++ b/src/pages/Pokedex/UseFilter.ts @@ -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[keyof Filter]) => { return (val: string) => { if (val === '') {