Notifications: Support mentions in muted groups (#3182)

This commit is contained in:
Alexander Zinchuk 2023-05-28 14:32:06 +02:00
parent c93b69c4fb
commit 233fff7eb5

View File

@ -264,11 +264,11 @@ export async function subscribe() {
} }
} }
function checkIfShouldNotify(chat: ApiChat) { function checkIfShouldNotify(chat: ApiChat, message: Partial<ApiMessage>) {
if (!areSettingsLoaded) return false; if (!areSettingsLoaded) return false;
const global = getGlobal(); const global = getGlobal();
const isMuted = selectIsChatMuted(chat, selectNotifySettings(global), selectNotifyExceptions(global)); const isMuted = selectIsChatMuted(chat, selectNotifySettings(global), selectNotifyExceptions(global));
if (isMuted || chat.isNotJoined || !chat.isListed) { if ((isMuted && !message.isMentioned) || chat.isNotJoined || !chat.isListed) {
return false; return false;
} }
// On touch devices show notifications when chat is not active // On touch devices show notifications when chat is not active
@ -420,7 +420,7 @@ export async function notifyAboutMessage({
isReaction = false, isReaction = false,
}: { chat: ApiChat; message: Partial<ApiMessage>; isReaction?: boolean }) { }: { chat: ApiChat; message: Partial<ApiMessage>; isReaction?: boolean }) {
const { hasWebNotifications } = await loadNotificationSettings(); const { hasWebNotifications } = await loadNotificationSettings();
if (!checkIfShouldNotify(chat)) return; if (!checkIfShouldNotify(chat, message)) return;
const areNotificationsSupported = checkIfNotificationsSupported(); const areNotificationsSupported = checkIfNotificationsSupported();
if (!hasWebNotifications || !areNotificationsSupported) { if (!hasWebNotifications || !areNotificationsSupported) {
if (!message.isSilent && !isReaction) { if (!message.isSilent && !isReaction) {