mirror of
https://github.com/danog/telegram-tt.git
synced 2024-11-30 04:39:00 +01:00
Notifications: Fix unneeded sound from reactions (#1756)
This commit is contained in:
parent
0b1fc0904e
commit
6d0d8a3419
@ -485,7 +485,7 @@ addReducer('apiUpdate', (global, actions, update: ApiUpdate) => {
|
||||
const chat = selectChat(global, update.chatId);
|
||||
const currentReactions = message?.reactions;
|
||||
|
||||
// `updateMessageReactions` happens with an interval so we try to avoid redundant global state updates
|
||||
// `updateMessageReactions` happens with an interval, so we try to avoid redundant global state updates
|
||||
if (currentReactions && areDeepEqual(reactions, currentReactions)) {
|
||||
return;
|
||||
}
|
||||
@ -501,6 +501,7 @@ addReducer('apiUpdate', (global, actions, update: ApiUpdate) => {
|
||||
notifyAboutMessage({
|
||||
chat,
|
||||
message: newMessage,
|
||||
isReaction: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -332,12 +332,15 @@ async function getAvatar(chat: ApiChat) {
|
||||
export async function notifyAboutMessage({
|
||||
chat,
|
||||
message,
|
||||
}: { chat: ApiChat; message: Partial<ApiMessage> }) {
|
||||
isReaction = false,
|
||||
}: { chat: ApiChat; message: Partial<ApiMessage>; isReaction?: boolean }) {
|
||||
const { hasWebNotifications } = await loadNotificationSettings();
|
||||
if (!checkIfShouldNotify(chat)) return;
|
||||
const areNotificationsSupported = checkIfNotificationsSupported();
|
||||
if (!hasWebNotifications || !areNotificationsSupported) {
|
||||
// only play sound if web notifications are disabled
|
||||
// Do not play notification sound for reactions if web notifications are disabled
|
||||
if (isReaction) return;
|
||||
// Only play sound if web notifications are disabled
|
||||
playNotifySoundDebounced(String(message.id) || chat.id);
|
||||
return;
|
||||
}
|
||||
@ -364,7 +367,7 @@ export async function notifyAboutMessage({
|
||||
icon,
|
||||
chatId: chat.id,
|
||||
messageId: message.id,
|
||||
reaction: activeReaction ? activeReaction.reaction : undefined,
|
||||
reaction: activeReaction?.reaction,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user