Notifications: Fix loading global settings (#1164)
This commit is contained in:
parent
5ca5be1d06
commit
558d453f21
@ -139,7 +139,7 @@ async function loadNotificationSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function subscribe() {
|
export async function subscribe() {
|
||||||
loadNotificationSettings();
|
await loadNotificationSettings();
|
||||||
|
|
||||||
if (!checkIfPushSupported()) {
|
if (!checkIfPushSupported()) {
|
||||||
// Ask for notification permissions only if service worker notifications are not supported
|
// 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) {
|
function checkIfShouldNotify(chat: ApiChat, isActive: boolean) {
|
||||||
const global = getGlobal();
|
const global = getGlobal();
|
||||||
|
|
||||||
if (selectIsChatMuted(chat, selectNotifySettings(global), selectNotifyExceptions(global)) || chat.isNotJoined) {
|
if (selectIsChatMuted(chat, selectNotifySettings(global), selectNotifyExceptions(global)) || chat.isNotJoined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dont show notification for active chat if client has focus
|
// Dont show notification for active chat if client has focus
|
||||||
if (isActive && document.hasFocus()) return false;
|
return !(isActive && document.hasFocus());
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNotificationContent(chat: ApiChat, message: ApiMessage) {
|
function getNotificationContent(chat: ApiChat, message: ApiMessage) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user