From 40512d729490091f61d645cc2e9eded9390ef26d Mon Sep 17 00:00:00 2001 From: Nyako <24845294+nyakowint@users.noreply.github.com> Date: Wed, 4 Sep 2024 20:16:41 -0400 Subject: [PATCH] XSOverlay: fix profile images (#2788) Fixes https://github.com/Vendicated/Vencord/issues/2787 Co-authored-by: v --- src/plugins/xsOverlay/index.tsx | 40 +++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/plugins/xsOverlay/index.tsx b/src/plugins/xsOverlay/index.tsx index 12dbf6b6..4c5b7a80 100644 --- a/src/plugins/xsOverlay/index.tsx +++ b/src/plugins/xsOverlay/index.tsx @@ -86,7 +86,7 @@ interface NotificationObject { title: string; content: string; useBase64Icon: boolean; - icon: ArrayBuffer | string; + icon: string; sourceApp: string; } @@ -320,23 +320,29 @@ function shouldIgnoreForChannelType(channel: Channel) { } function sendMsgNotif(titleString: string, content: string, message: Message) { - fetch(`https://cdn.discordapp.com/avatars/${message.author.id}/${message.author.avatar}.png?size=128`).then(response => response.arrayBuffer()).then(result => { - const msgData: NotificationObject = { - type: 1, - timeout: settings.store.lengthBasedTimeout ? calculateTimeout(content) : settings.store.timeout, - height: calculateHeight(content), - opacity: settings.store.opacity, - volume: settings.store.volume, - audioPath: settings.store.soundPath, - title: titleString, - content: content, - useBase64Icon: true, - icon: new TextDecoder().decode(result), - sourceApp: "Vencord" - }; + fetch(`https://cdn.discordapp.com/avatars/${message.author.id}/${message.author.avatar}.png?size=128`) + .then(response => response.blob()) + .then(blob => new Promise(resolve => { + const r = new FileReader(); + r.onload = () => resolve((r.result as string).split(",")[1]); + r.readAsDataURL(blob); + })).then(result => { + const msgData: NotificationObject = { + type: 1, + timeout: settings.store.lengthBasedTimeout ? calculateTimeout(content) : settings.store.timeout, + height: calculateHeight(content), + opacity: settings.store.opacity, + volume: settings.store.volume, + audioPath: settings.store.soundPath, + title: titleString, + content: content, + useBase64Icon: true, + icon: result, + sourceApp: "Vencord" + }; - sendToOverlay(msgData); - }); + sendToOverlay(msgData); + }); } function sendOtherNotif(content: string, titleString: string) {