simplify a bit and remove debug logging

This commit is contained in:
or-else
2023-01-09 11:21:30 -08:00
parent ba94788fbe
commit acc24b552d
5 changed files with 6 additions and 14 deletions
+2 -6
View File
@@ -373,16 +373,12 @@ class TinodeWeb extends React.Component {
try {
this.fcm = firebaseGetMessaging(firebaseInitApp(FIREBASE_INIT, APP_NAME));
return navigator.serviceWorker.getRegistration('/service-worker.js').then(reg => {
if (reg) {
return reg
}
return navigator.serviceWorker.register('/service-worker.js').then(reg => {
return reg || navigator.serviceWorker.register('/service-worker.js').then(reg => {
this.checkForAppUpdate(reg);
return reg;
});
}).then(reg => {
// Pass locale and version config to the service worker.
console.log("SW active:", reg.active, "installing:", reg.installing);
(reg.active || reg.installing).postMessage(JSON.stringify({locale: locale, version: PACKAGE_VERSION}));
// Request token.
return TinodeWeb.requestFCMToken(this.fcm, reg);
@@ -402,7 +398,7 @@ class TinodeWeb extends React.Component {
// Handhe FCM pushes
// (a) for channels always,
// (b) pushes when the app is in foreground but has no focus.
firebaseOnMessage(this.fcm, (payload) => { this.handlePushMessage(payload); });
firebaseOnMessage(this.fcm, payload => { this.handlePushMessage(payload); });
}).catch(err => {
// SW registration or FCM has failed :(
onError(err);