From 558d453f21367152f368510b99c4c26f82d42e86 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Tue, 15 Jun 2021 13:21:35 +0300 Subject: [PATCH] Notifications: Fix loading global settings (#1164) --- src/util/notifications.ts | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/src/util/notifications.ts b/src/util/notifications.ts index 3d30761b9..aa0dad4a6 100644 --- a/src/util/notifications.ts +++ b/src/util/notifications.ts @@ -139,7 +139,7 @@ async function loadNotificationSettings() { } export async function subscribe() { - loadNotificationSettings(); + await loadNotificationSettings(); if (!checkIfPushSupported()) { // Ask for notification permissions only if service worker notifications are not supported @@ -191,25 +191,11 @@ export async function subscribe() { function checkIfShouldNotify(chat: ApiChat, isActive: boolean) { const global = getGlobal(); - if (selectIsChatMuted(chat, selectNotifySettings(global), selectNotifyExceptions(global)) || chat.isNotJoined) { return false; } - // Dont show notification for active chat if client has focus - if (isActive && document.hasFocus()) return false; - - switch (chat.type) { - case 'chatTypePrivate': - case 'chatTypeSecret': - return Boolean(global.settings.byKey.hasPrivateChatsNotifications); - case 'chatTypeBasicGroup': - case 'chatTypeSuperGroup': - return Boolean(global.settings.byKey.hasGroupNotifications); - case 'chatTypeChannel': - return Boolean(global.settings.byKey.hasBroadcastNotifications); - } - return false; + return !(isActive && document.hasFocus()); } function getNotificationContent(chat: ApiChat, message: ApiMessage) {