Revert "Done to stop breaks on testing"

This reverts commit fe3d4922e4.
This commit is contained in:
Core 2022-06-23 04:01:01 +01:00
parent fe3d4922e4
commit 009fae24fc
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6

View file

@ -2,7 +2,6 @@ import * as ElectronStore from 'electron-store';
import * as electron from "electron"; import * as electron from "electron";
import {app} from "electron"; import {app} from "electron";
import fetch from "electron-fetch"; import fetch from "electron-fetch";
export class Store { export class Store {
static cfg: ElectronStore; static cfg: ElectronStore;
@ -58,7 +57,7 @@ export class Store {
"CommandOrControl", "CommandOrControl",
"G" "G"
], ],
"songs": [ "songs" : [
"CommandOrControl", "CommandOrControl",
"J" "J"
], ],
@ -81,17 +80,17 @@ export class Store {
], ],
"audioSettings": [ "audioSettings": [
"CommandOrControl", "CommandOrControl",
process.platform == "darwin" ? "Option" : (process.platform == "linux" ? "Shift" : "Alt"), process.platform == "darwin" ? "Option" : (process.platform == "linux" ? "Shift": "Alt"),
"A" "A"
], ],
"pluginMenu": [ "pluginMenu": [
"CommandOrControl", "CommandOrControl",
process.platform == "darwin" ? "Option" : (process.platform == "linux" ? "Shift" : "Alt"), process.platform == "darwin" ? "Option" : (process.platform == "linux" ? "Shift": "Alt"),
"P" "P"
], ],
"castToDevices": [ "castToDevices": [
"CommandOrControl", "CommandOrControl",
process.platform == "darwin" ? "Option" : (process.platform == "linux" ? "Shift" : "Alt"), process.platform == "darwin" ? "Option" : (process.platform == "linux" ? "Shift": "Alt"),
"C" "C"
], ],
"settings": [ "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<any> = { private schema: ElectronStore.Schema<any> = {
"connectivity.discord_rpc": { "connectivity.discord_rpc": {
type: 'object' type: 'object'
@ -273,51 +278,13 @@ export class Store {
defaults: this.defaults, defaults: this.defaults,
schema: this.schema, schema: this.schema,
migrations: this.migrations, migrations: this.migrations,
clearInvalidConfig: false //disabled for now clearInvalidConfig: true
}); });
Store.cfg.set(this.mergeStore(this.defaults, Store.cfg.store)) Store.cfg.set(this.mergeStore(this.defaults, Store.cfg.store))
this.ipcHandler(); 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 * Merge Configurations
* @param target The target configuration * @param target The target configuration
@ -339,6 +306,7 @@ export class Store {
return target return target
} }
/** /**
* IPC Handler * IPC Handler
*/ */
@ -359,4 +327,43 @@ export class Store {
Store.cfg.store = 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)
})
}
} }