Revert "Merge branch 'develop' of https://github.com/ciderapp/Cider into develop"
This reverts commitbd3a2b6172
, reversing changes made to0fb6802ff3
.
This commit is contained in:
parent
35aa69c2d6
commit
4bed3ca783
5 changed files with 66 additions and 48 deletions
|
@ -88,7 +88,7 @@ export class BrowserWindow {
|
||||||
y: undefined,
|
y: undefined,
|
||||||
minWidth: 900,
|
minWidth: 900,
|
||||||
minHeight: 390,
|
minHeight: 390,
|
||||||
frame: (process.platform === "linux"),
|
frame: false,
|
||||||
title: "Cider",
|
title: "Cider",
|
||||||
vibrancy: "fullscreen-ui",
|
vibrancy: "fullscreen-ui",
|
||||||
transparent: process.platform === "darwin",
|
transparent: process.platform === "darwin",
|
||||||
|
@ -130,7 +130,6 @@ export class BrowserWindow {
|
||||||
this.startWebServer();
|
this.startWebServer();
|
||||||
|
|
||||||
BrowserWindow.win = new bw(this.options);
|
BrowserWindow.win = new bw(this.options);
|
||||||
BrowserWindow.win.setMenuBarVisibility(false)
|
|
||||||
const ws = new wsapi(BrowserWindow.win)
|
const ws = new wsapi(BrowserWindow.win)
|
||||||
ws.InitWebSockets()
|
ws.InitWebSockets()
|
||||||
// and load the renderer.
|
// and load the renderer.
|
||||||
|
|
|
@ -9,6 +9,7 @@ export class Store {
|
||||||
"close_button_hide": false,
|
"close_button_hide": false,
|
||||||
"open_on_startup": false,
|
"open_on_startup": false,
|
||||||
"discord_rpc": 1, // 0 = disabled, 1 = enabled as Cider, 2 = enabled as Apple Music
|
"discord_rpc": 1, // 0 = disabled, 1 = enabled as Cider, 2 = enabled as Apple Music
|
||||||
|
"discord_rpc_clear_on_pause": true,
|
||||||
"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"
|
||||||
|
|
|
@ -8,8 +8,8 @@ export default class DiscordRichPresence {
|
||||||
* Private variables for interaction in plugins
|
* Private variables for interaction in plugins
|
||||||
*/
|
*/
|
||||||
private static _store: any;
|
private static _store: any;
|
||||||
private _app: any;
|
private _app : any;
|
||||||
private _attributes: any;
|
private _attributes : any;
|
||||||
private static _connection: boolean = false;
|
private static _connection: boolean = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,10 +76,10 @@ export default class DiscordRichPresence {
|
||||||
|
|
||||||
// Login to Discord
|
// Login to Discord
|
||||||
this._client.login({clientId})
|
this._client.login({clientId})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
DiscordRichPresence._connection = true;
|
DiscordRichPresence._connection = true;
|
||||||
})
|
})
|
||||||
.catch((e: any) => console.error(`[DiscordRichPresence][connect] ${e}`));
|
.catch((e: any) => console.error(`[DiscordRichPresence][connect] ${e}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,43 +94,43 @@ export default class DiscordRichPresence {
|
||||||
}).catch((e: any) => console.error(`[DiscordRPC][disconnect] ${e}`));
|
}).catch((e: any) => console.error(`[DiscordRPC][disconnect] ${e}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the Discord activity object
|
* Filter the Discord activity object
|
||||||
*/
|
*/
|
||||||
private filterActivity(activity: any, attributes: any): Object {
|
private filterActivity(activity: any, attributes: any): Object {
|
||||||
|
|
||||||
// Checks if the name is greater than 128 because some songs can be that long
|
// Checks if the name is greater than 128 because some songs can be that long
|
||||||
if (activity.details && activity.details.length > 128) {
|
if (activity.details && activity.details.length > 128) {
|
||||||
activity.details = activity.details.substring(0, 125) + '...'
|
activity.details = activity.details.substring(0, 125) + '...'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check large image
|
// Check large image
|
||||||
if (activity.largeImageKey == null || activity.largeImageKey === "" || activity.largeImageKey.length > 256) {
|
if (activity.largeImageKey == null || activity.largeImageKey === "" || activity.largeImageKey.length > 256) {
|
||||||
activity.largeImageKey = "cider";
|
activity.largeImageKey = "cider";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timestamp
|
// Timestamp
|
||||||
if (new Date(attributes.endTime).getTime() < 0) {
|
if (new Date(attributes.endTime).getTime() < 0) {
|
||||||
delete activity.startTime
|
delete activity.startTime
|
||||||
delete activity.endTime
|
delete activity.endTime
|
||||||
}
|
}
|
||||||
|
|
||||||
// not sure
|
// not sure
|
||||||
if (!attributes.artistName) {
|
if (!attributes.artistName) {
|
||||||
delete activity.state;
|
delete activity.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!activity.largeImageText || activity.largeImageText.length < 2) {
|
if (!activity.largeImageText || activity.largeImageText.length < 2) {
|
||||||
delete activity.largeImageText
|
delete activity.largeImageText
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.buttons.forEach((key: { label: string, url: string }, _v: Number) => {
|
activity.buttons.forEach((key: {label: string, url: string}, _v: Number) => {
|
||||||
if (key.url.includes('undefined') || key.url.includes('no-id-found')) {
|
if (key.url.includes('undefined') || key.url.includes('no-id-found')) {
|
||||||
activity.buttons.splice(key, 1);
|
activity.buttons.splice(key, 1);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return activity
|
return activity
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the activity of the client
|
* Sets the activity of the client
|
||||||
|
@ -158,15 +158,29 @@ export default class DiscordRichPresence {
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
this._activity = this.filterActivity(this._activity, attributes)
|
this._activity = this.filterActivity(this._activity, attributes)
|
||||||
|
|
||||||
// Check if its pausing (false) or playing (true)
|
// Check if its pausing (false) or playing (true)
|
||||||
if (!attributes.status) {
|
if (!attributes.status) {
|
||||||
this._client.clearActivity()
|
if (DiscordRichPresence._store.general.discord_rpc_clear_on_pause) {
|
||||||
|
this._client.clearActivity()
|
||||||
.catch((e: any) => console.error(`[DiscordRichPresence][clearActivity] ${e}`));
|
.catch((e: any) => console.error(`[DiscordRichPresence][clearActivity] ${e}`));
|
||||||
|
} else {
|
||||||
|
this._activity.smallImageKey = 'pause';
|
||||||
|
this._activity.smallImageText = 'Paused';
|
||||||
|
delete this._activity.endTimestamp;
|
||||||
|
delete this._activity.startTimestamp;
|
||||||
|
this._client.setActivity(this._activity)
|
||||||
|
.catch((e: any) => console.error(`[DiscordRichPresence][setActivity] ${e}`));
|
||||||
|
}
|
||||||
} else if (this._activity && this._activityCache !== this._activity && this._activity.details) {
|
} else if (this._activity && this._activityCache !== this._activity && this._activity.details) {
|
||||||
|
if (!DiscordRichPresence._store.general.discord_rpc_clear_on_pause) {
|
||||||
|
this._activity.smallImageKey = 'play';
|
||||||
|
this._activity.smallImageText = 'Playing';
|
||||||
|
}
|
||||||
|
|
||||||
this._client.setActivity(this._activity)
|
this._client.setActivity(this._activity)
|
||||||
.catch((e: any) => console.error(`[DiscordRichPresence][updateActivity] ${e}`));
|
.catch((e: any) => console.error(`[DiscordRichPresence][updateActivity] ${e}`));
|
||||||
this._activityCache = this._activity;
|
this._activityCache = this._activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,20 +207,20 @@ export default class DiscordRichPresence {
|
||||||
this.connect((DiscordRichPresence._store.general.discord_rpc == 1) ? '911790844204437504' : '886578863147192350');
|
this.connect((DiscordRichPresence._store.general.discord_rpc == 1) ? '911790844204437504' : '886578863147192350');
|
||||||
console.debug(`[Plugin][${this.name}] Ready.`);
|
console.debug(`[Plugin][${this.name}] Ready.`);
|
||||||
ipcMain.on('updateRPCImage', (_event, imageurl) => {
|
ipcMain.on('updateRPCImage', (_event, imageurl) => {
|
||||||
fetch('https://api.cider.sh/v1/images', {
|
fetch('https://api.cider.sh/v1/images' ,{
|
||||||
|
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({url: imageurl}),
|
body: JSON.stringify({url : imageurl}),
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'User-Agent': _win.webContents.getUserAgent()
|
'User-Agent': _win.webContents.getUserAgent()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(function (json) {
|
.then(function(json){
|
||||||
self._attributes["artwork"]["url"] = json.url
|
self._attributes["artwork"]["url"] = json.url
|
||||||
self.updateActivity(self._attributes)
|
self.updateActivity(self._attributes)
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -3134,10 +3134,6 @@ body[platform='darwin'] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body[platform='linux'] #window-controls-container {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.percent {
|
.percent {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
|
@ -568,6 +568,14 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="md-option-line" v-show="app.cfg.general.discord_rpc != 0">
|
||||||
|
<div class="md-option-segment">
|
||||||
|
{{$root.getLz('settings.option.connectivity.discordRPC.clearOnPause')}}
|
||||||
|
</div>
|
||||||
|
<div class="md-option-segment md-option-segment_auto">
|
||||||
|
<input type="checkbox" v-model="app.cfg.general.discord_rpc_clear_on_pause" switch/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="md-option-line">
|
<div class="md-option-line">
|
||||||
<div class="md-option-segment">
|
<div class="md-option-segment">
|
||||||
{{$root.getLz('settings.option.connectivity.lastfmScrobble')}}
|
{{$root.getLz('settings.option.connectivity.lastfmScrobble')}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue