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() {
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.`);