mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-05-22 14:56:38 +01:00
fix(seerr): migrate legacy Jellyseerr settings and storage keys
The Jellyseerr -> Seerr rebrand renamed the settings property (jellyseerrServerUrl -> seerrServerUrl) and the MMKV storage keys (JELLYSEERR_USER/COOKIES -> SEERR_USER/COOKIES). Without migration, users who configured Seerr before the rename lose their server URL and are silently logged out on update. Adds one-time migrations: loadSettings copies the legacy property, and useSeerr migrates the storage keys at module load before the user atom is read.
This commit is contained in:
@@ -65,6 +65,35 @@ interface SearchResults {
|
||||
const SEERR_USER = "SEERR_USER";
|
||||
const SEERR_COOKIES = "SEERR_COOKIES";
|
||||
|
||||
// One-time migration of the legacy Jellyseerr storage keys to the Seerr-branded
|
||||
// keys. Runs at module load, before seerrUserAtom reads SEERR_USER, so logged-in
|
||||
// users keep their session through the rename instead of being silently logged out.
|
||||
const LEGACY_USER_KEY = "JELLYSEERR_USER";
|
||||
const LEGACY_COOKIES_KEY = "JELLYSEERR_COOKIES";
|
||||
|
||||
function migrateLegacySeerrStorage() {
|
||||
const legacyUser = storage.get<SeerrUser>(LEGACY_USER_KEY);
|
||||
if (
|
||||
legacyUser !== undefined &&
|
||||
storage.get<SeerrUser>(SEERR_USER) === undefined
|
||||
) {
|
||||
storage.setAny(SEERR_USER, legacyUser);
|
||||
}
|
||||
|
||||
const legacyCookies = storage.get<string[]>(LEGACY_COOKIES_KEY);
|
||||
if (
|
||||
legacyCookies !== undefined &&
|
||||
storage.get<string[]>(SEERR_COOKIES) === undefined
|
||||
) {
|
||||
storage.setAny(SEERR_COOKIES, legacyCookies);
|
||||
}
|
||||
|
||||
storage.remove(LEGACY_USER_KEY);
|
||||
storage.remove(LEGACY_COOKIES_KEY);
|
||||
}
|
||||
|
||||
migrateLegacySeerrStorage();
|
||||
|
||||
export const clearSeerrStorageData = () => {
|
||||
storage.remove(SEERR_USER);
|
||||
storage.remove(SEERR_COOKIES);
|
||||
|
||||
@@ -304,6 +304,19 @@ const loadSettings = (): Partial<Settings> => {
|
||||
const loadedValues: Partial<Settings> =
|
||||
jsonValue != null ? JSON.parse(jsonValue) : {};
|
||||
|
||||
// Migration: jellyseerrServerUrl -> seerrServerUrl (renamed in the Seerr rebrand).
|
||||
// Without this, users who configured Seerr before the rename lose their server URL.
|
||||
const legacy = loadedValues as Partial<Settings> & {
|
||||
jellyseerrServerUrl?: string;
|
||||
};
|
||||
if (legacy.jellyseerrServerUrl !== undefined) {
|
||||
if (legacy.seerrServerUrl === undefined) {
|
||||
legacy.seerrServerUrl = legacy.jellyseerrServerUrl;
|
||||
}
|
||||
delete legacy.jellyseerrServerUrl;
|
||||
storage.set("settings", JSON.stringify(loadedValues));
|
||||
}
|
||||
|
||||
return loadedValues;
|
||||
} catch (error) {
|
||||
console.error("Failed to load settings:", error);
|
||||
|
||||
Reference in New Issue
Block a user