XSOverlay: fix profile images (#2788)

Fixes https://github.com/Vendicated/Vencord/issues/2787

Co-authored-by: v <vendicated@riseup.net>
This commit is contained in:
Nyako 2024-09-04 20:16:41 -04:00 committed by GitHub
parent be02baffaa
commit 40512d7294
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -86,7 +86,7 @@ interface NotificationObject {
title: string; title: string;
content: string; content: string;
useBase64Icon: boolean; useBase64Icon: boolean;
icon: ArrayBuffer | string; icon: string;
sourceApp: string; sourceApp: string;
} }
@ -320,23 +320,29 @@ function shouldIgnoreForChannelType(channel: Channel) {
} }
function sendMsgNotif(titleString: string, content: string, message: Message) { 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 => { fetch(`https://cdn.discordapp.com/avatars/${message.author.id}/${message.author.avatar}.png?size=128`)
const msgData: NotificationObject = { .then(response => response.blob())
type: 1, .then(blob => new Promise<string>(resolve => {
timeout: settings.store.lengthBasedTimeout ? calculateTimeout(content) : settings.store.timeout, const r = new FileReader();
height: calculateHeight(content), r.onload = () => resolve((r.result as string).split(",")[1]);
opacity: settings.store.opacity, r.readAsDataURL(blob);
volume: settings.store.volume, })).then(result => {
audioPath: settings.store.soundPath, const msgData: NotificationObject = {
title: titleString, type: 1,
content: content, timeout: settings.store.lengthBasedTimeout ? calculateTimeout(content) : settings.store.timeout,
useBase64Icon: true, height: calculateHeight(content),
icon: new TextDecoder().decode(result), opacity: settings.store.opacity,
sourceApp: "Vencord" 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) { function sendOtherNotif(content: string, titleString: string) {