tmp
This commit is contained in:
parent
064b287553
commit
1e2978199e
2 changed files with 22 additions and 3 deletions
|
@ -1,4 +1,6 @@
|
|||
import * as RPC from 'discord-rpc'
|
||||
import {ipcMain} from "electron";
|
||||
import fetch from 'electron-fetch'
|
||||
|
||||
export default class DiscordRichPresence {
|
||||
|
||||
|
@ -6,6 +8,7 @@ export default class DiscordRichPresence {
|
|||
* Private variables for interaction in plugins
|
||||
*/
|
||||
private static _store: any;
|
||||
private _app : any;
|
||||
private static _connection: boolean = false;
|
||||
|
||||
/**
|
||||
|
@ -29,6 +32,7 @@ export default class DiscordRichPresence {
|
|||
smallImageText: '',
|
||||
instance: false
|
||||
};
|
||||
|
||||
private _activityCache: RPC.Presence = {
|
||||
details: '',
|
||||
state: '',
|
||||
|
@ -101,7 +105,7 @@ export default class DiscordRichPresence {
|
|||
}
|
||||
|
||||
// Check large image
|
||||
if (activity.largeImageKey === null || activity.largeImageKey === ""){
|
||||
if (activity.largeImageKey == null || activity.largeImageKey === "" || activity.largeImageKey.length > 256) {
|
||||
activity.largeImageKey = "cider";
|
||||
}
|
||||
|
||||
|
@ -169,7 +173,6 @@ export default class DiscordRichPresence {
|
|||
this._client.setActivity(this._activity)
|
||||
.catch((e: any) => console.error(`[DiscordRichPresence][setActivity] ${e}`));
|
||||
}
|
||||
|
||||
} else if (this._activity && this._activityCache !== this._activity && this._activity.details) {
|
||||
if (!DiscordRichPresence._store.general.discord_rpc_clear_on_pause) {
|
||||
this._activity.smallImageKey = 'play';
|
||||
|
@ -190,9 +193,10 @@ export default class DiscordRichPresence {
|
|||
/**
|
||||
* Runs on plugin load (Currently run on application start)
|
||||
*/
|
||||
constructor(_app: any, store: any) {
|
||||
constructor(app: any, store: any) {
|
||||
DiscordRichPresence._store = store
|
||||
console.debug(`[Plugin][${this.name}] Loading Complete.`);
|
||||
this._app = app;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,6 +205,20 @@ export default class DiscordRichPresence {
|
|||
onReady(_win: any): void {
|
||||
this.connect((DiscordRichPresence._store.general.discord_rpc == 1) ? '911790844204437504' : '886578863147192350');
|
||||
console.debug(`[Plugin][${this.name}] Ready.`);
|
||||
// ipcMain.on('updateRPCImage', (_event, imageurl) => {
|
||||
// fetch('https://api.cider.sh/v1/images' ,{
|
||||
|
||||
// method: 'POST',
|
||||
// body: JSON.stringify({url : imageurl}),
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// 'User-Agent': 'Cider Development Environment'
|
||||
// },
|
||||
// })
|
||||
// .then(res => res.text())
|
||||
// .then(json => console.log(json))
|
||||
|
||||
// })
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3109,6 +3109,7 @@ const app = new Vue({
|
|||
data = data.data.data[0];
|
||||
if (data != null && data !== "" && data.attributes != null && data.attributes.artwork != null) {
|
||||
this.currentArtUrl = (data["attributes"]["artwork"]["url"] ?? '').replace('{w}', 50).replace('{h}', 50);
|
||||
ipcRenderer.send('updateRPCImage', this.currentArtUrl ?? '');
|
||||
try {
|
||||
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue