aboutsummaryrefslogtreecommitdiff
path: root/src/stores/settings.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/settings.ts')
-rw-r--r--src/stores/settings.ts29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/stores/settings.ts b/src/stores/settings.ts
index 1edab858..1e77afbd 100644
--- a/src/stores/settings.ts
+++ b/src/stores/settings.ts
@@ -6,7 +6,7 @@ import identity from "./identity";
import settingsSyncPulled from "./settingsSyncPulled";
import settingsSyncTimes from "./settingsSyncTimes";
-const VERSION = "1.0.1";
+const VERSION = "1.0.2";
export interface Settings {
cacheMangaMinutes: number;
@@ -49,7 +49,7 @@ export interface Settings {
disableUpcomingAnime: boolean;
display24HourTime: boolean;
displayCountdownRightAligned: boolean;
- displayNativeCountdown: boolean;
+ countdownSource: "native" | "sub" | "dub";
displayHoverCover: boolean;
displayDisableAnimations: boolean;
displayDisableNotifications: boolean;
@@ -101,7 +101,7 @@ const defaultSettings: Settings = {
disableUpcomingAnime: false,
display24HourTime: false,
displayCountdownRightAligned: false,
- displayNativeCountdown: false,
+ countdownSource: "sub",
displayHoverCover: false,
displayDisableAnimations: false,
displayDisableNotifications: false,
@@ -147,11 +147,28 @@ const defaultSettings: Settings = {
settingsVersion: VERSION,
};
+// Carry the retired `displayNativeCountdown` boolean over to `countdownSource`.
+const migrateSettings = (stored: Settings): Settings => {
+ const legacy = stored as Settings & { displayNativeCountdown?: boolean };
+
+ if (
+ legacy.countdownSource === undefined &&
+ legacy.displayNativeCountdown !== undefined
+ )
+ legacy.countdownSource = legacy.displayNativeCountdown ? "native" : "sub";
+
+ delete legacy.displayNativeCountdown;
+
+ return legacy;
+};
+
const createStore = () => {
const initialValue = browser
- ? parseJsonStringOrDefault(
- localStorage.getItem("settings") || "",
- defaultSettings,
+ ? migrateSettings(
+ parseJsonStringOrDefault(
+ localStorage.getItem("settings") || "",
+ defaultSettings,
+ ),
)
: defaultSettings;
const store = writable<Settings>(initialValue);