diff --git a/src/core/patches.ts b/src/core/patches.ts index 219565f7c..83da033bd 100644 --- a/src/core/patches.ts +++ b/src/core/patches.ts @@ -18,7 +18,7 @@ export const webuiSettingsPatches = { delete webuiSettings.collection.poster.showRandomPoster; webuiSettings.collection.image = { showRandomPoster: - (oldWebuiSettings?.collection?.list?.showRandomPoster || oldWebuiSettings?.collection?.poster?.showRandomPoster) + (oldWebuiSettings.collection.list.showRandomPoster || oldWebuiSettings.collection.poster.showRandomPoster) ?? false, showRandomFanart: false, }; diff --git a/src/core/react-query/settings/helpers.ts b/src/core/react-query/settings/helpers.ts index adf614454..9f181bfb6 100644 --- a/src/core/react-query/settings/helpers.ts +++ b/src/core/react-query/settings/helpers.ts @@ -400,21 +400,27 @@ export const transformSettings = (response: SettingsServerType) => { let webuiSettings = JSON.parse( response.WebUI_Settings === '' ? '{}' : response.WebUI_Settings, ) as WebUISettingsType; - const settingsRevision = webuiSettings.settingsRevision ?? 0; - if (settingsRevision < 4) { - webuiSettings = { - ...initialSettings.WebUI_Settings, - settingsRevision: Number(Object.keys(webuiSettingsPatches).pop()), - }; + const currentSettingsRevision = webuiSettings.settingsRevision ?? 0; + const versionedInitialSettings: WebUISettingsType = { + ...initialSettings.WebUI_Settings, + settingsRevision: Number(Object.keys(webuiSettingsPatches).pop()), + }; + + if (currentSettingsRevision < 4) { + webuiSettings = versionedInitialSettings; } else { - Object - .keys(webuiSettingsPatches) - .map(Number) - .filter(key => key > settingsRevision) - .forEach((key) => { - webuiSettings = webuiSettingsPatches[key](webuiSettings); - }); - webuiSettings = Object.assign({}, initialSettings.WebUI_Settings, webuiSettings); + try { + Object + .keys(webuiSettingsPatches) + .map(Number) + .filter(key => key > currentSettingsRevision) + .forEach((key) => { + webuiSettings = webuiSettingsPatches[key](webuiSettings); + }); + webuiSettings = Object.assign({}, initialSettings.WebUI_Settings, webuiSettings); + } catch { + webuiSettings = versionedInitialSettings; + } } return { ...response, WebUI_Settings: webuiSettings } as SettingsType; // For Dev Only