From 2d76befea1b444656c8dc0206806414e18df159e Mon Sep 17 00:00:00 2001 From: or-else Date: Tue, 10 Jan 2023 17:18:34 -0800 Subject: [PATCH] fix missed calls when topic is not in focus --- service-worker.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/service-worker.js b/service-worker.js index bec4dd87..b69d4a6c 100644 --- a/service-worker.js +++ b/service-worker.js @@ -64,16 +64,16 @@ const fbMessaging = firebase.messaging(); // This method shows the push notifications while the window is in background. fbMessaging.onBackgroundMessage(payload => { - if (payload.data.silent == 'true') { - // TODO: if this is an 'msg', fetch the new message in the background. - return; - } - // Notify webapp that a message was received. if (webAppChannel) { webAppChannel.postMessage(payload.data); } + if (payload.data.silent == 'true') { + // No need to show anything. + return; + } + const titles = {'msg': 'new_message', 'sub': 'new_chat'}; const pushType = payload.data.what || 'msg'; const title = payload.data.title || self.i18nMessage(titles[pushType]);