From f698e4566483a94ca0b0dba68ddadc2c9734a772 Mon Sep 17 00:00:00 2001 From: SpacingBat3 Date: Mon, 29 Aug 2022 00:24:49 +0200 Subject: [PATCH] ...again, regenerate hashes. Now, I've decided to actually hash the string directly, as I've noticed varrying results when Electon has sometimes "crashed". I've also added a check to prevent hashing empty strings and probably getting invalid results. --- sources/code/common/global.ts | 4 ++-- sources/code/main/windows/main.ts | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/sources/code/common/global.ts b/sources/code/common/global.ts index ced2fd51..2e118c58 100644 --- a/sources/code/common/global.ts +++ b/sources/code/common/global.ts @@ -24,8 +24,8 @@ export function isJsonSyntaxCorrect(string: string) { /** SHA1 hashes of Discord favicons (in RAW bitmap format). */ export const discordFavicons = { /** Default favicon (without *blue dot* indicator). */ - default: "a971976200e0abf8d8a9fad46b7309363ef3cd01", - unread: "3133ab8ef98ea83f1573f6c3902c027015c005bf" + default: "6f637da8422057ec825c3249f2b37714de34a65b", + unread: "f88f58f3f6689b21c3a3426c4c76855f9ad2044c" }; /** diff --git a/sources/code/main/windows/main.ts b/sources/code/main/windows/main.ts index d3c0e2c2..52979fab 100644 --- a/sources/code/main/windows/main.ts +++ b/sources/code/main/windows/main.ts @@ -15,7 +15,6 @@ import { BrowserView, systemPreferences } from "electron/main"; -import { NativeImage, nativeImage } from "electron/common"; import * as getMenu from "../modules/menu"; import { discordFavicons, knownInstancesList } from "../../common/global"; import packageJson from "../../common/modules/package"; @@ -281,11 +280,10 @@ export default function createMainWindow(flags:MainWindowFlags): BrowserWindow { // "Red dot" icon feature let setFavicon: string | undefined; win.webContents.on("page-favicon-updated", (_event, favicons) => { - let icon: NativeImage, flash = false; - // Convert from DataURL to RAW. - const faviconBuffer = nativeImage.createFromDataURL(favicons[0]??"").toPNG(); + if(favicons[0] === undefined) return; + let icon: Electron.NativeImage, flash = false; // Hash discord favicon. - const faviconHash = createHash("sha1").update(faviconBuffer).digest("hex"); + const faviconHash = createHash("sha1").update(favicons[0]).digest("hex"); // Stop execution when icon is same as the one set. if (faviconHash === setFavicon) return; // Stop code execution on Fosscord instances.