From b7272271623da6fe56ca9ea21bff73fe11aa6c08 Mon Sep 17 00:00:00 2001 From: skattkookie Date: Sat, 28 Feb 2026 12:48:19 +0000 Subject: [PATCH] Added notifcation when you're name is mentioned --- src/native/sounds.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/native/sounds.ts b/src/native/sounds.ts index 993322f..4e908e8 100644 --- a/src/native/sounds.ts +++ b/src/native/sounds.ts @@ -110,6 +110,31 @@ export function injectSounds(webContents: Electron.WebContents) { playUserLeaveSound(); } + if (data.type === "Message" && data.mentions?.includes(currentUserId) && data.author !== currentUserId) { + playMentionSound(); + const cachedName = userNameCache[data.author]; + if (cachedName) { + const myName = userNameCache[currentUserId] || 'you'; + const content = data.content?.replace(/<@[^>]+>/g, '@' + myName).trim() || "New message"; + __showMentionToast(cachedName, 'mention', content); + } else { + // fetch user from API if not cached + fetch('https://api.revolt.chat/users/' + data.author) + .then(r => r.json()) + .then(user => { + const name = user.username || data.author; + userNameCache[data.author] = name; + const myName = userNameCache[currentUserId] || 'you'; + const content = data.content?.replace(/<@[^>]+>/g, '@' + myName).trim() || "New message"; + __showMentionToast(name, 'mention', content); + }) + .catch(() => { + const content = data.content?.replace(/<@[^>]+>/g, '').trim() || "New message"; + __showMentionToast(data.author, 'mention', content); + }); + } + } + if (data.type === "Message" && data.role_mentions?.length > 0 && data.member?.roles?.length > 0) { const matchedRoleId = data.role_mentions.find(roleId => data.member.roles.includes(roleId)); if (matchedRoleId) {