1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-23 02:05:27 +02:00

New: Improve stored UI settings for multiple instances under the same host

Closes #7368
This commit is contained in:
Mark McDowall 2024-11-05 22:00:26 -08:00 committed by Mark McDowall
parent e28b7c3df6
commit 6677fd1116

View File

@ -96,14 +96,22 @@ function merge(initialState, persistedState) {
return computedState;
}
const KEY = 'sonarr';
const config = {
slicer,
serialize,
merge,
key: 'sonarr'
key: window.Sonarr.instanceName.toLowerCase().replace(/ /g, '_') || KEY
};
export default function createPersistState() {
// Migrate existing local storage value to new key if it does not already exist.
// Leave old value as-is in case there are multiple instances using the same key.
if (config.key !== KEY && localStorage.getItem(KEY) && !localStorage.getItem(config.key)) {
localStorage.setItem(config.key, localStorage.getItem(KEY));
}
// Migrate existing local storage before proceeding
const persistedState = JSON.parse(localStorage.getItem(config.key));
migrate(persistedState);