Use activity cache

This commit is contained in:
Core 2022-10-27 10:17:00 +01:00
parent 9b247a413f
commit 143e435017
No known key found for this signature in database
GPG key ID: 2AB8327FBA02D1C0

View file

@ -57,21 +57,21 @@ export default class DiscordRPC {
*/ */
onRendererReady() { onRendererReady() {
const self = this; const self = this;
ipcMain.on("discordrpc:updateImage", async (_event, imageurl) => { ipcMain.on("discordrpc:updateImage", async (_event, artworkUrl) => {
if (!this._utils.getStoreValue("general.privateEnabled")) { if (this._utils.getStoreValue("general.privateEnabled")) return;
fetch("https://api.cider.sh/v1/images", {
method: "POST", fetch("https://api.cider.sh/v1/images", {
headers: { method: "POST",
"User-Agent": this._utils.getWindow().webContents.getUserAgent(), headers: {
url: imageurl, "User-Agent": this._utils.getWindow().webContents.getUserAgent(),
}, url: artworkUrl,
}) },
.then((res) => res.json()) })
.then(function (json) { .then((res) => res.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. .then(function (json) {
self.setActivity(self._attributes); 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) => { ipcMain.on("discordrpc:reload", (_event, configUpdate = null) => {
console.log(`[DiscordRPC][reload] Reloading DiscordRPC.`); console.log(`[DiscordRPC][reload] Reloading DiscordRPC.`);