mirror of
https://github.com/immich-app/immich.git
synced 2024-12-28 06:31:58 +00:00
fix(web): infinite loop browser navigation crash admin settings page (#14850)
* fix(web): infinite loop browser navigation crash admin settings page * pr feedback
This commit is contained in:
parent
d5906c2efe
commit
6080e6e827
1 changed files with 9 additions and 10 deletions
|
@ -9,9 +9,9 @@
|
||||||
import { writable, type Writable } from 'svelte/store';
|
import { writable, type Writable } from 'svelte/store';
|
||||||
import { createContext } from '$lib/utils/context';
|
import { createContext } from '$lib/utils/context';
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
import { handlePromiseError } from '$lib/utils';
|
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import type { Snippet } from 'svelte';
|
import type { Snippet } from 'svelte';
|
||||||
|
import { handlePromiseError } from '$lib/utils';
|
||||||
|
|
||||||
const getParamValues = (param: string) => {
|
const getParamValues = (param: string) => {
|
||||||
return new Set((page.url.searchParams.get(param) || '').split(' ').filter((x) => x !== ''));
|
return new Set((page.url.searchParams.get(param) || '').split(' ').filter((x) => x !== ''));
|
||||||
|
@ -26,17 +26,16 @@
|
||||||
let { queryParam, state = writable(getParamValues(queryParam)), children }: Props = $props();
|
let { queryParam, state = writable(getParamValues(queryParam)), children }: Props = $props();
|
||||||
setAccordionState(state);
|
setAccordionState(state);
|
||||||
|
|
||||||
$effect(() => {
|
const searchParams = new URLSearchParams(page.url.searchParams);
|
||||||
if (queryParam && $state) {
|
|
||||||
const searchParams = new URLSearchParams(page.url.searchParams);
|
|
||||||
if ($state.size > 0) {
|
|
||||||
searchParams.set(queryParam, [...$state].join(' '));
|
|
||||||
} else {
|
|
||||||
searchParams.delete(queryParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
handlePromiseError(goto(`?${searchParams.toString()}`, { replaceState: true, noScroll: true, keepFocus: true }));
|
$effect(() => {
|
||||||
|
if ($state.size > 0) {
|
||||||
|
searchParams.set(queryParam, [...$state].join(' '));
|
||||||
|
} else {
|
||||||
|
searchParams.delete(queryParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlePromiseError(goto(`?${searchParams.toString()}`, { replaceState: true, noScroll: true, keepFocus: true }));
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue