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