Skip to content

Commit

Permalink
Merge pull request #23 from bookracy/fix/migrate-backend-url-and-disc…
Browse files Browse the repository at this point in the history
…ord-link

Migrate to new backend url for old storages, change discord url
  • Loading branch information
JorrinKievit authored Sep 3, 2024
2 parents 776c1cc + 1ea1771 commit 25a5996
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<RoutePaths<typeof routeTree>, string>> = {
Expand Down
14 changes: 14 additions & 0 deletions src/stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SettingsStoreState>()(
persist(
(set) => ({
Expand All @@ -27,6 +35,12 @@ export const useSettingsStore = create<SettingsStoreState>()(
{
name: "BR::settings",
storage: createJSONStorage(() => localStorage),
version: 1,
migrate(persistedState, version) {
if (version === 0 && isOldState(persistedState)) {
return { ...persistedState, backendURL: "https://backend.bookracy.ru" };
}
},
},
),
);

0 comments on commit 25a5996

Please sign in to comment.