fix(web): isolate paginated filter scopes

This commit is contained in:
lingniu
2026-07-16 04:44:21 +08:00
parent d95d7ab735
commit 14525887ea
7 changed files with 137 additions and 10 deletions

View File

@@ -7,3 +7,11 @@ export const QUERY_MEMORY = {
export function retainPreviousPageWithinScope<T>(scope: string) {
return (previous: T | undefined, previousQuery?: { queryKey: readonly unknown[] }) => previousQuery?.queryKey[1] === scope ? previous : undefined;
}
export function queryScopeKey(query: object) {
return Object.entries(query)
.filter(([, value]) => value !== undefined && value !== null && value !== '')
.sort(([left], [right]) => left.localeCompare(right))
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`)
.join('&');
}