fix(web): settings accordion open state (#7504)

This commit is contained in:
Michel Heusschen 2024-02-28 22:40:08 +01:00 committed by GitHub
parent 84fe41df31
commit 93f0a866a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 108 additions and 107 deletions

View file

@ -1,5 +1,3 @@
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { NotificationType, notificationController } from '$lib/components/shared-components/notification/notification';
import { locales } from '$lib/constants';
import { handleError } from '$lib/utils/handle-error';
@ -14,37 +12,6 @@ import {
unlinkOAuthAccount,
type UserResponseDto,
} from '@immich/sdk';
import { get } from 'svelte/store';
interface UpdateParamAction {
param: string;
value: string;
add: boolean;
}
const getParamValues = (param: string) =>
new Set((get(page).url.searchParams.get(param) || '').split(' ').filter((x) => x !== ''));
export const hasParamValue = (param: string, value: string) => getParamValues(param).has(value);
export const updateParamList = async ({ param, value, add }: UpdateParamAction) => {
const values = getParamValues(param);
if (add) {
values.add(value);
} else {
values.delete(value);
}
const searchParams = new URLSearchParams(get(page).url.searchParams);
searchParams.set(param, [...values.values()].join(' '));
if (values.size === 0) {
searchParams.delete(param);
}
await goto(`?${searchParams.toString()}`, { replaceState: true, noScroll: true, keepFocus: true });
};
export const getJobName = (jobName: JobName) => {
const names: Record<JobName, string> = {