store update with new options and migration to prevent errors

This commit is contained in:
Core 2022-04-14 14:37:39 +01:00
parent 5a2229cf67
commit d47c784bad
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6

View file

@ -12,9 +12,14 @@ export class Store {
}, },
"general": { "general": {
"close_button_hide": false, "close_button_hide": false,
"discord_rpc": 1, // 0 = disabled, 1 = enabled as Cider, 2 = enabled as Apple Music "discord_rpc": {
"discord_rpc_clear_on_pause": true, "enabled": false,
"discord_rpc_hide_buttons": false, "client": "Cider",
"clear_on_pause": true,
"hide_buttons": false,
"state_format": "by {artist}",
"details_format": "{title}",
},
"language": "en_US", // electron.app.getLocale().replace('-', '_') this can be used in future "language": "en_US", // electron.app.getLocale().replace('-', '_') this can be used in future
"playbackNotifications": true, "playbackNotifications": true,
"update_branch": "main", "update_branch": "main",
@ -152,13 +157,20 @@ export class Store {
"playlistTrackMapping": true "playlistTrackMapping": true
} }
} }
private migrations: any = {} private migrations: any = {
'1.4.3': (store: ElectronStore) => {
if (typeof(store.get('general.discord_rpc')) == 'number') {
store.set('general.discord_rpc', this.defaults.general.discord_rpc)
}
},
}
constructor() { constructor() {
Store.cfg = new ElectronStore({ Store.cfg = new ElectronStore({
name: 'cider-config', name: 'cider-config',
defaults: this.defaults, defaults: this.defaults,
migrations: this.migrations, migrations: this.migrations,
clearInvalidConfig: true
}); });
Store.cfg.set(this.mergeStore(this.defaults, Store.cfg.store)) Store.cfg.set(this.mergeStore(this.defaults, Store.cfg.store))