From 3ec6715836bd28b59e7851d05b8c95574c262fb7 Mon Sep 17 00:00:00 2001 From: mkljczk Date: Tue, 18 Mar 2025 10:49:32 +0100 Subject: [PATCH] pl-fe: fix disappearing notifications filter bug Signed-off-by: mkljczk --- packages/pl-fe/src/stores/settings.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/pl-fe/src/stores/settings.ts b/packages/pl-fe/src/stores/settings.ts index ffabd2991..758737e57 100644 --- a/packages/pl-fe/src/stores/settings.ts +++ b/packages/pl-fe/src/stores/settings.ts @@ -35,13 +35,16 @@ type State = { rememberLanguageUse: (language: string) => void; } -const changeSetting = (object: APIEntity, path: string[], value: any) => { +const changeSetting = (object: APIEntity, path: string[], value: any, root?: Settings) => { if (path.length === 1) { object[path[0]] = value; return; } - if (typeof object[path[0]] !== 'object') object[path[0]] = {}; + if (typeof object[path[0]] !== 'object') { + const value = root && root[path[0] as keyof Settings] as APIEntity || {}; + object[path[0]] = value; + } return changeSetting(object[path[0]], path.slice(1), value); }; @@ -88,7 +91,7 @@ const useSettingsStore = create()(mutative((set) => ({ changeSetting: (path: string[], value: any) => set((state: State) => { state.userSettings.saved = false; - changeSetting(state.userSettings, path, value); + changeSetting(state.userSettings, path, value, state.defaultSettings); mergeSettings(state, true); }),