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:
parent
e28b7c3df6
commit
6677fd1116
@ -96,14 +96,22 @@ function merge(initialState, persistedState) {
|
|||||||
return computedState;
|
return computedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const KEY = 'sonarr';
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
slicer,
|
slicer,
|
||||||
serialize,
|
serialize,
|
||||||
merge,
|
merge,
|
||||||
key: 'sonarr'
|
key: window.Sonarr.instanceName.toLowerCase().replace(/ /g, '_') || KEY
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function createPersistState() {
|
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
|
// Migrate existing local storage before proceeding
|
||||||
const persistedState = JSON.parse(localStorage.getItem(config.key));
|
const persistedState = JSON.parse(localStorage.getItem(config.key));
|
||||||
migrate(persistedState);
|
migrate(persistedState);
|
||||||
|
Loading…
Reference in New Issue
Block a user