Renamed config var to discordrpc because this migration shit is giving me a headache

This commit is contained in:
Core 2022-05-02 05:09:38 +01:00
parent 47a48673e6
commit 12be570a98
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6
3 changed files with 23 additions and 23 deletions

View file

@ -12,7 +12,7 @@ export class Store {
},
"general": {
"close_button_hide": false,
"discord_rpc": {
"discordrpc": {
"enabled": false,
"client": "Cider",
"clear_on_pause": true,
@ -221,13 +221,13 @@ export class Store {
}
private migrations: any = {
'>=1.4.3': (store: ElectronStore) => {
if (typeof store.get('general.discord_rpc') == 'number' || typeof store.get('general.discord_rpc') == 'string') {
store.delete('general.discord_rpc');
if (typeof store.get('general.discordrpc') == 'number' || typeof store.get('general.discordrpc') == 'string') {
store.delete('general.discordrpc');
}
},
}
private schema: ElectronStore.Schema<any> = {
"general.discord_rpc": {
"general.discordrpc": {
type: 'object'
},
}

View file

@ -53,10 +53,10 @@ export default class DiscordRPC {
* @private
*/
private connect() {
if (!this._utils.getStoreValue("general.discord_rpc.enabled")) {
if (!this._utils.getStoreValue("general.discordrpc.enabled")) {
return;
}
const clientId = this._utils.getStoreValue("general.discord_rpc.client") === "Cider" ? '911790844204437504' : '886578863147192350';
const clientId = this._utils.getStoreValue("general.discordrpc.client") === "Cider" ? '911790844204437504' : '886578863147192350';
// Apparently needed for ask to join, join, spectate etc.
RPC.register(clientId)
@ -187,7 +187,7 @@ export default class DiscordRPC {
activity = DiscordRPC.filterActivity(activity, this._attributes)
// Set the activity
if (!this._attributes.status && this._utils.getStoreValue("general.discord_rpc.clear_on_pause")) {
if (!this._attributes.status && this._utils.getStoreValue("general.discordrpc.clear_on_pause")) {
this._client.clearActivity()
} else if (this._activity && this._activityCache !== this._activity && this._activity.details) {
this._client.setActivity(activity)
@ -200,7 +200,7 @@ export default class DiscordRPC {
* @param {object} attributes
*/
private updateActivity(attributes: any) {
if (!this._utils.getStoreValue("general.discord_rpc.enabled") || this._utils.getStoreValue("general.privateEnabled")) {
if (!this._utils.getStoreValue("general.discordrpc.enabled") || this._utils.getStoreValue("general.privateEnabled")) {
return
} else if (!this._client || !this._connection) {
this.connect()
@ -208,15 +208,15 @@ export default class DiscordRPC {
// Check if show buttons is (true) or (false)
this._activity = {
details: this._utils.getStoreValue("general.discord_rpc.details_format"),
state: this._utils.getStoreValue("general.discord_rpc.state_format"),
details: this._utils.getStoreValue("general.discordrpc.details_format"),
state: this._utils.getStoreValue("general.discordrpc.state_format"),
largeImageKey: attributes?.artwork?.url?.replace('{w}', '1024').replace('{h}', '1024'),
largeImageText: attributes.albumName,
instance: false // Whether the activity is in a game session
}
// Add the buttons if people want them
if (!this._utils.getStoreValue("general.discord_rpc.hide_buttons")) {
if (!this._utils.getStoreValue("general.discordrpc.hide_buttons")) {
this._activity.buttons = [
{label: 'Listen on Cider', url: attributes.url.cider},
{label: 'View on Apple Music', url: attributes.url.appleMusic}
@ -230,7 +230,7 @@ export default class DiscordRPC {
}
// If the user wants to keep the activity when paused
if (!this._utils.getStoreValue("general.discord_rpc.clear_on_pause")) {
if (!this._utils.getStoreValue("general.discordrpc.clear_on_pause")) {
this._activity.smallImageKey = attributes.status ? 'play' : 'pause';
this._activity.smallImageText = attributes.status ? 'Playing' : 'Paused';
}

View file

@ -1013,18 +1013,18 @@
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.general.discord_rpc.enabled" switch/>
<input type="checkbox" v-model="app.cfg.general.discordrpc.enabled" switch/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discord_rpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.clientName')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<select class="md-select" v-model="app.cfg.general.discord_rpc.client">
<select class="md-select" v-model="app.cfg.general.discordrpc.client">
<option value="Cider">{{$root.getLz('app.name')}}</option>
<option value="AppleMusic">{{$root.getLz('term.appleMusic')}}
</option>
@ -1033,29 +1033,29 @@
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discord_rpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.clearOnPause')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.general.discord_rpc.clear_on_pause" switch/>
<input type="checkbox" v-model="app.cfg.general.discordrpc.clear_on_pause" switch/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discord_rpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.hideButtons')}}
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="checkbox" v-model="app.cfg.general.discord_rpc.hide_buttons" switch/>
<input type="checkbox" v-model="app.cfg.general.discordrpc.hide_buttons" switch/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discord_rpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.detailsFormat')}}<br/>
<small>{{$root.getLz('term.variables')}}: {artist}, {composer}, {title}, {album},
@ -1063,12 +1063,12 @@
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="text" v-model="app.cfg.general.discord_rpc.details_format"/>
<input type="text" v-model="app.cfg.general.discordrpc.details_format"/>
</label>
</div>
</div>
<div class="md-option-line" v-show="app.cfg.general.discord_rpc.enabled != false">
<div class="md-option-line" v-show="app.cfg.general.discordrpc.enabled != false">
<div class="md-option-segment">
{{$root.getLz('settings.option.connectivity.discordRPC.stateFormat')}}
<small>{{$root.getLz('term.variables')}}: {artist}, {composer}, {title}, {album},
@ -1076,7 +1076,7 @@
</div>
<div class="md-option-segment md-option-segment_auto">
<label>
<input type="text" v-model="app.cfg.general.discord_rpc.state_format"/>
<input type="text" v-model="app.cfg.general.discordrpc.state_format"/>
</label>
</div>
</div>