diff --git a/src/constants.ts b/src/constants.ts index 8a61022..36f3058 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -2,7 +2,7 @@ import { RoutePaths } from "@tanstack/react-router"; import { routeTree } from "./routeTree.gen"; export const GITHUB_URL = "https://github.com/bookracy"; -export const DISCORD_URL = "https://discord.gg/6YKQn8Sg"; +export const DISCORD_URL = "https://discord.gg/bookracy"; export const X_URL = "https://x.com/bookracy"; export const PAGE_TITLES: Partial, string>> = { diff --git a/src/stores/settings.ts b/src/stores/settings.ts index 4b25a64..39475e6 100644 --- a/src/stores/settings.ts +++ b/src/stores/settings.ts @@ -13,6 +13,14 @@ interface SettingsStoreState { setTheme: (theme: Theme) => void; } +const isOldState = (oldState: unknown): oldState is SettingsStoreState => { + if (typeof oldState !== "object" || oldState === null) { + return false; + } + + return "language" in oldState && "backendURL" in oldState && "theme" in oldState; +}; + export const useSettingsStore = create()( persist( (set) => ({ @@ -27,6 +35,12 @@ export const useSettingsStore = create()( { name: "BR::settings", storage: createJSONStorage(() => localStorage), + version: 1, + migrate(persistedState, version) { + if (version === 0 && isOldState(persistedState)) { + return { ...persistedState, backendURL: "https://backend.bookracy.ru" }; + } + }, }, ), );