From 143e435017553448e911458f64320d48a9d83901 Mon Sep 17 00:00:00 2001 From: Core Date: Thu, 27 Oct 2022 10:17:00 +0100 Subject: [PATCH] Use activity cache --- src/main/plugins/discordrpc.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/plugins/discordrpc.ts b/src/main/plugins/discordrpc.ts index 352a31c8..bc2607d7 100644 --- a/src/main/plugins/discordrpc.ts +++ b/src/main/plugins/discordrpc.ts @@ -57,21 +57,21 @@ export default class DiscordRPC { */ onRendererReady() { const self = this; - ipcMain.on("discordrpc:updateImage", async (_event, imageurl) => { - if (!this._utils.getStoreValue("general.privateEnabled")) { - fetch("https://api.cider.sh/v1/images", { - method: "POST", - headers: { - "User-Agent": this._utils.getWindow().webContents.getUserAgent(), - url: imageurl, - }, - }) - .then((res) => res.json()) - .then(function (json) { - self._attributes["artwork"]["url"] = "https://images.weserv.nl/?url=" + json.imageUrl + "&w=600&h=600&output=jpg"; // Image Caching Proxy to prevent Discord from going haha no. - self.setActivity(self._attributes); - }); - } + ipcMain.on("discordrpc:updateImage", async (_event, artworkUrl) => { + if (this._utils.getStoreValue("general.privateEnabled")) return; + + fetch("https://api.cider.sh/v1/images", { + method: "POST", + headers: { + "User-Agent": this._utils.getWindow().webContents.getUserAgent(), + url: artworkUrl, + }, + }) + .then((res) => res.json()) + .then(function (json) { + self._activityCache.largeImageKey = "https://images.weserv.nl/?url=" + json.imageUrl + "&w=600&h=600&output=jpg"; + self._client.setActivity(self._activityCache); + }); }); ipcMain.on("discordrpc:reload", (_event, configUpdate = null) => { console.log(`[DiscordRPC][reload] Reloading DiscordRPC.`);