Moved discord and lastfm config to connectivity
This commit is contained in:
parent
e3225e9ad5
commit
2abefe21a0
4 changed files with 66 additions and 64 deletions
|
@ -12,15 +12,6 @@ export class Store {
|
|||
},
|
||||
"general": {
|
||||
"close_button_hide": false,
|
||||
"discordrpc": {
|
||||
"enabled": true,
|
||||
"client": "Cider",
|
||||
"clear_on_pause": true,
|
||||
"hide_buttons": false,
|
||||
"hide_timestamp": false,
|
||||
"state_format": "by {artist}",
|
||||
"details_format": "{title}",
|
||||
},
|
||||
"language": "en_US", // electron.app.getLocale().replace('-', '_') this can be used in future
|
||||
"playbackNotifications": true,
|
||||
"resumeOnStartupBehavior": "local",
|
||||
|
@ -114,6 +105,27 @@ export class Store {
|
|||
},
|
||||
"showLovedTracksInline": true
|
||||
},
|
||||
"connectivity": {
|
||||
"discord_rpc": {
|
||||
"enabled": true,
|
||||
"client": "Cider",
|
||||
"clear_on_pause": true,
|
||||
"hide_buttons": false,
|
||||
"hide_timestamp": false,
|
||||
"state_format": "by {artist}",
|
||||
"details_format": "{title}",
|
||||
},
|
||||
"lastfm": {
|
||||
"enabled": false,
|
||||
"scrobble_after": 50,
|
||||
"filter_loop": false,
|
||||
"secrets": {
|
||||
"username": "",
|
||||
"key": ""
|
||||
}
|
||||
|
||||
},
|
||||
},
|
||||
"home": {
|
||||
"followedArtists": [],
|
||||
"favoriteItems": []
|
||||
|
@ -219,16 +231,6 @@ export class Store {
|
|||
"enable_qq": false,
|
||||
"enable_yt": false,
|
||||
},
|
||||
"lastfm": {
|
||||
"enabled": false,
|
||||
"scrobble_after": 50,
|
||||
"filter_loop": false,
|
||||
"secrets": {
|
||||
"username": "",
|
||||
"key": ""
|
||||
}
|
||||
|
||||
},
|
||||
"advanced": {
|
||||
"AudioContext": false,
|
||||
"experiments": [],
|
||||
|
@ -246,13 +248,13 @@ export class Store {
|
|||
}
|
||||
private migrations: any = {
|
||||
'>=1.4.3': (store: ElectronStore) => {
|
||||
if (typeof store.get('general.discordrpc') == 'number' || typeof store.get('general.discordrpc') == 'string') {
|
||||
store.delete('general.discordrpc');
|
||||
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> = {
|
||||
"general.discordrpc": {
|
||||
"connectivity.discord_rpc": {
|
||||
type: 'object'
|
||||
},
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ export default class DiscordRPC {
|
|||
console.log(`[DiscordRPC][reload] Reloading DiscordRPC.`);
|
||||
this._client.destroy()
|
||||
|
||||
this._client.endlessLogin({clientId: this._utils.getStoreValue("general.discordrpc.client") === "Cider" ? '911790844204437504' : '886578863147192350'})
|
||||
this._client.endlessLogin({clientId: this._utils.getStoreValue("connectivity.discord_rpc.client") === "Cider" ? '911790844204437504' : '886578863147192350'})
|
||||
.then(() => {
|
||||
this.ready = true
|
||||
this._utils.getWindow().webContents.send("rpcReloaded", this._client.user)
|
||||
|
@ -125,7 +125,7 @@ export default class DiscordRPC {
|
|||
* @private
|
||||
*/
|
||||
private connect() {
|
||||
if (!this._utils.getStoreValue("general.discordrpc.enabled")) {
|
||||
if (!this._utils.getStoreValue("connectivity.discord_rpc.enabled")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ export default class DiscordRPC {
|
|||
})
|
||||
|
||||
// Login to Discord
|
||||
this._client.endlessLogin({clientId: this._utils.getStoreValue("general.discordrpc.client") === "Cider" ? '911790844204437504' : '886578863147192350'})
|
||||
this._client.endlessLogin({clientId: this._utils.getStoreValue("connectivity.discord_rpc.client") === "Cider" ? '911790844204437504' : '886578863147192350'})
|
||||
.then(() => {
|
||||
this.ready = true
|
||||
})
|
||||
|
@ -161,8 +161,8 @@ export default class DiscordRPC {
|
|||
|
||||
// Check if show buttons is (true) or (false)
|
||||
let activity: Object = {
|
||||
details: this._utils.getStoreValue("general.discordrpc.details_format"),
|
||||
state: this._utils.getStoreValue("general.discordrpc.state_format"),
|
||||
details: this._utils.getStoreValue("connectivity.discord_rpc.details_format"),
|
||||
state: this._utils.getStoreValue("connectivity.discord_rpc.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
|
||||
|
@ -177,7 +177,7 @@ export default class DiscordRPC {
|
|||
}
|
||||
|
||||
// Set the activity
|
||||
if (!attributes.status && this._utils.getStoreValue("general.discordrpc.clear_on_pause")) {
|
||||
if (!attributes.status && this._utils.getStoreValue("connectivity.discord_rpc.clear_on_pause")) {
|
||||
this._client.clearActivity()
|
||||
} else if (activity && this._activityCache !== activity) {
|
||||
this._client.setActivity(activity)
|
||||
|
@ -191,7 +191,7 @@ export default class DiscordRPC {
|
|||
private filterActivity(activity: any, attributes: any): Object {
|
||||
|
||||
// Add the buttons if people want them
|
||||
if (!this._utils.getStoreValue("general.discordrpc.hide_buttons")) {
|
||||
if (!this._utils.getStoreValue("connectivity.discord_rpc.hide_buttons")) {
|
||||
activity.buttons = [
|
||||
{label: 'Listen on Cider', url: attributes.url.cider},
|
||||
{label: 'View on Apple Music', url: attributes.url.appleMusic}
|
||||
|
@ -199,13 +199,13 @@ export default class DiscordRPC {
|
|||
}
|
||||
|
||||
// Add the timestamp if its playing and people want them
|
||||
if (!this._utils.getStoreValue("general.discordrpc.hide_timestamp") && attributes.status) {
|
||||
if (!this._utils.getStoreValue("connectivity.discord_rpc.hide_timestamp") && attributes.status) {
|
||||
activity.startTimestamp = Date.now() - (attributes?.durationInMillis - attributes?.remainingTime)
|
||||
activity.endTimestamp = attributes.endTime
|
||||
}
|
||||
|
||||
// If the user wants to keep the activity when paused
|
||||
if (!this._utils.getStoreValue("general.discordrpc.clear_on_pause")) {
|
||||
if (!this._utils.getStoreValue("connectivity.discord_rpc.clear_on_pause")) {
|
||||
activity.smallImageKey = attributes.status ? 'play' : 'pause';
|
||||
activity.smallImageText = attributes.status ? 'Playing' : 'Paused';
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ export default class lastfm {
|
|||
})
|
||||
|
||||
this._utils.getIPCMain().on('lastfm:nowPlayingChange', (event: any, attributes: any) => {
|
||||
if (this._utils.getStoreValue("lastfm.filter_loop")) return;
|
||||
if (this._utils.getStoreValue("connectivity.lastfm.filter_loop")) return;
|
||||
this.onNowPlayingItemDidChange(attributes)
|
||||
})
|
||||
}
|
||||
|
@ -96,8 +96,8 @@ export default class lastfm {
|
|||
'secret': api.secret,
|
||||
});
|
||||
|
||||
if (this._utils.getStoreValue("lastfm.secrets.username") && this._utils.getStoreValue("lastfm.secrets.key")) {
|
||||
this._lfm.setSessionCredentials(this._utils.getStoreValue("lastfm.secrets.username"), this._utils.getStoreValue("lastfm.secrets.key"));
|
||||
if (this._utils.getStoreValue("connectivity.lastfm.secrets.username") && this._utils.getStoreValue("connectivity.lastfm.secrets.key")) {
|
||||
this._lfm.setSessionCredentials(this._utils.getStoreValue("connectivity.lastfm.secrets.username"), this._utils.getStoreValue("connectivity.lastfm.secrets.key"));
|
||||
this._authenticated = true;
|
||||
} else {
|
||||
this.authenticateLastFM(token)
|
||||
|
@ -170,7 +170,7 @@ export default class lastfm {
|
|||
* @private
|
||||
*/
|
||||
private scrobbleTrack(attributes: any): void {
|
||||
if (!this._authenticated || !attributes || (this._utils.getStoreValue("lastfm.filter_loop") && this._scrobbleCache.track === attributes.lfmTrack.name)) return;
|
||||
if (!this._authenticated || !attributes || (this._utils.getStoreValue("connectivity.lastfm.filter_loop") && this._scrobbleCache.track === attributes.lfmTrack.name)) return;
|
||||
|
||||
if (this._scrobbleDelay) {
|
||||
clearTimeout(this._scrobbleDelay);
|
||||
|
@ -204,11 +204,11 @@ export default class lastfm {
|
|||
this._scrobbleCache = scrobble
|
||||
}
|
||||
});
|
||||
}, Math.round(attributes.durationInMillis * Math.min((this._utils.getStoreValue("lastfm.scrobble_after") / 100), 0.8)))
|
||||
}, Math.round(attributes.durationInMillis * Math.min((this._utils.getStoreValue("connectivity.lastfm.scrobble_after") / 100), 0.8)))
|
||||
}
|
||||
|
||||
private updateNowPlayingTrack(attributes: any): void {
|
||||
if (!this._authenticated || !attributes || (this._utils.getStoreValue("lastfm.filter_loop") && this._nowPlayingCache.track === attributes.lfmTrack.name)) return;
|
||||
if (!this._authenticated || !attributes || (this._utils.getStoreValue("connectivity.lastfm.filter_loop") && this._nowPlayingCache.track === attributes.lfmTrack.name)) return;
|
||||
|
||||
const nowPlaying = {
|
||||
'artist': attributes.lfmTrack.artist.name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue