From f8e43992af1e3903331db05ec14a6a2d3049bd36 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sat, 9 Dec 2023 21:45:33 -0800 Subject: feat(settings): add new keys to settings --- src/stores/settings.ts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/stores/settings.ts') diff --git a/src/stores/settings.ts b/src/stores/settings.ts index c57a6268..4a94bc4f 100644 --- a/src/stores/settings.ts +++ b/src/stores/settings.ts @@ -22,6 +22,10 @@ export interface Settings { displayPlannedAnime: boolean; displayFurigana: boolean; displayAoButa: 'mai' | 'nodoka' | 'kaede' | 'none'; + disableManga: boolean; + disableAnime: boolean; + disableUpcomingAnime: boolean; + [key: string]: unknown; } const defaultSettings: Settings = { @@ -40,6 +44,9 @@ const defaultSettings: Settings = { closeMangaByDefault: false, sortByDifference: false, displayAoButa: 'mai', + disableManga: false, + disableAnime: false, + disableUpcomingAnime: false, // Calculation roundDownChapters: true, @@ -74,13 +81,19 @@ const createStore = () => { const settingsKeys = Object.keys(state); if (keys.length !== settingsKeys.length) { - return defaultSettings; - } + const updatedSettings = { ...state }; + + for (const key of keys) { + if (!settingsKeys.includes(key)) { + updatedSettings[key] = defaultSettings[key as keyof Settings]; + } + } - for (const key of keys) { - if (!settingsKeys.includes(key)) { - return defaultSettings; + if (browser) { + localStorage.setItem('settings', JSON.stringify(updatedSettings)); } + + return updatedSettings; } return state; -- cgit v1.2.3