From 009fae24fc17d1ca003cd8a6a0c8e59e8e948f50 Mon Sep 17 00:00:00 2001 From: Core <64542347+coredev-uk@users.noreply.github.com> Date: Thu, 23 Jun 2022 04:01:01 +0100 Subject: [PATCH] Revert "Done to stop breaks on testing" This reverts commit fe3d4922e443438682fba199970a7aa08b7e2677. --- src/main/base/store.ts | 97 ++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 45 deletions(-) diff --git a/src/main/base/store.ts b/src/main/base/store.ts index fef12bc8..db16f9b1 100644 --- a/src/main/base/store.ts +++ b/src/main/base/store.ts @@ -2,7 +2,6 @@ import * as ElectronStore from 'electron-store'; import * as electron from "electron"; import {app} from "electron"; import fetch from "electron-fetch"; - export class Store { static cfg: ElectronStore; @@ -58,7 +57,7 @@ export class Store { "CommandOrControl", "G" ], - "songs": [ + "songs" : [ "CommandOrControl", "J" ], @@ -81,17 +80,17 @@ export class Store { ], "audioSettings": [ "CommandOrControl", - process.platform == "darwin" ? "Option" : (process.platform == "linux" ? "Shift" : "Alt"), + process.platform == "darwin" ? "Option" : (process.platform == "linux" ? "Shift": "Alt"), "A" ], "pluginMenu": [ "CommandOrControl", - process.platform == "darwin" ? "Option" : (process.platform == "linux" ? "Shift" : "Alt"), + process.platform == "darwin" ? "Option" : (process.platform == "linux" ? "Shift": "Alt"), "P" ], "castToDevices": [ "CommandOrControl", - process.platform == "darwin" ? "Option" : (process.platform == "linux" ? "Shift" : "Alt"), + process.platform == "darwin" ? "Option" : (process.platform == "linux" ? "Shift": "Alt"), "C" ], "settings": [ @@ -260,7 +259,13 @@ export class Store { } }, } - private migrations: any = {} + private migrations: any = { + '>=1.4.3': (store: ElectronStore) => { + if (typeof store.get('connectivity.discord_rpc') == 'number' || typeof store.get('connectivity.discord_rpc') == 'string') { + store.delete('connectivity.discord_rpc'); + } + }, + } private schema: ElectronStore.Schema = { "connectivity.discord_rpc": { type: 'object' @@ -273,51 +278,13 @@ export class Store { defaults: this.defaults, schema: this.schema, migrations: this.migrations, - clearInvalidConfig: false //disabled for now + clearInvalidConfig: true }); Store.cfg.set(this.mergeStore(this.defaults, Store.cfg.store)) this.ipcHandler(); } - static pushToCloud(): void { - if (Store.cfg.get('connectUser.auth') === null) return; - var syncData = Object(); - if (Store.cfg.get('connectUser.sync.themes')) { - syncData.push({ - themes: Store.cfg.store.themes - }) - } - if (Store.cfg.get('connectUser.sync.plugins')) { - syncData.push({ - plugins: Store.cfg.store.plugins - }) - } - - if (Store.cfg.get('connectUser.sync.settings')) { - syncData.push({ - general: Store.cfg.get('general'), - home: Store.cfg.get('home'), - libraryPrefs: Store.cfg.get('libraryPrefs'), - advanced: Store.cfg.get('advanced'), - }) - } - let postBody = { - id: Store.cfg.get('connectUser.id'), - app: electron.app.getName(), - version: electron.app.isPackaged ? electron.app.getVersion() : 'dev', - syncData: syncData - } - - fetch('https://connect.cidercollective.dev/api/v1/setttings/set', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(postBody) - }) - } - /** * Merge Configurations * @param target The target configuration @@ -339,6 +306,7 @@ export class Store { return target } + /** * IPC Handler */ @@ -359,4 +327,43 @@ export class Store { Store.cfg.store = store }) } + + + static pushToCloud(): void { + if (Store.cfg.get('connectUser.auth') === null) return; + var syncData = Object(); + if (Store.cfg.get('connectUser.sync.themes')) { + syncData.push({ + themes: Store.cfg.store.themes + }) + } + if (Store.cfg.get('connectUser.sync.plugins')) { + syncData.push({ + plugins: Store.cfg.store.plugins + }) + } + + if (Store.cfg.get('connectUser.sync.settings')) { + syncData.push({ + general: Store.cfg.get('general'), + home: Store.cfg.get('home'), + libraryPrefs: Store.cfg.get('libraryPrefs'), + advanced: Store.cfg.get('advanced'), + }) + } + let postBody = { + id: Store.cfg.get('connectUser.id'), + app: electron.app.getName(), + version: electron.app.isPackaged ? electron.app.getVersion() : 'dev', + syncData: syncData + } + + fetch('https://connect.cidercollective.dev/api/v1/setttings/set', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(postBody) + }) + } }