From f2622099d16197a46c2b51344aec848d57b95e05 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Sat, 8 May 2021 14:28:48 +0300 Subject: [PATCH] Push Notifications: Do not show muted (#1063) --- src/serviceWorker/pushNotification.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/serviceWorker/pushNotification.ts b/src/serviceWorker/pushNotification.ts index db1de2bf9..ba90d4452 100644 --- a/src/serviceWorker/pushNotification.ts +++ b/src/serviceWorker/pushNotification.ts @@ -2,6 +2,11 @@ import { DEBUG } from '../config'; declare const self: ServiceWorkerGlobalScope; +enum Boolean { + True = '1', + False = '0' +} + export type NotificationData = { custom: { msg_id?: string; @@ -9,8 +14,8 @@ export type NotificationData = { chat_id?: string; from_id?: string; }; - mute: '0' | '1'; - badge: '0' | '1'; + mute: Boolean; + badge: Boolean; loc_key: string; loc_args: string[]; random_id: number; @@ -42,7 +47,9 @@ export function handlePush(e: PushEvent) { } } const data = getPushData(e); - if (!data) return; + + // Do not show muted notifications + if (!data || data.mute === Boolean.True) return; const title = data.title || process.env.APP_INFO!; const body = data.description;