From b8780d468b9c72aa72802d913b4baea0c7e5d439 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 14 Dec 2020 16:34:38 +0100 Subject: [PATCH] Fix ReferenceError with Notification --- www/common/sframe-common-outer.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index b7610f684..ca760efb8 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -97,6 +97,7 @@ define([ '/common/common-hash.js', '/common/common-util.js', '/common/common-realtime.js', + '/common/notify.js', '/common/common-constants.js', '/common/common-feedback.js', '/common/outer/local-store.js', @@ -105,7 +106,7 @@ define([ '/common/test.js', '/common/userObject.js', ], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, _SFrameChannel, - _SecureIframe, _Messaging, _Notifier, _Hash, _Util, _Realtime, + _SecureIframe, _Messaging, _Notifier, _Hash, _Util, _Realtime, _Notify, _Constants, _Feedback, _LocalStore, _Cache, _AppConfig, _Test, _UserObject) { CpNfOuter = _CpNfOuter; Cryptpad = _Cryptpad; @@ -123,6 +124,7 @@ define([ Utils.LocalStore = _LocalStore; Utils.Cache = _Cache; Utils.UserObject = _UserObject; + Utils.Notify = _Notify; Utils.currentPad = currentPad; AppConfig = _AppConfig; Test = _Test; @@ -564,6 +566,7 @@ define([ defaultTitle: defaultTitle, type: cfg.type || parsed.type }; + var notifs = Utils.Notify.isSupported() && Utils.Notify.hasPermission(); var additionalPriv = { app: parsed.type, loggedIn: Utils.LocalStore.isLoggedIn(), @@ -578,7 +581,7 @@ define([ isPresent: parsed.hashData && parsed.hashData.present, isEmbed: parsed.hashData && parsed.hashData.embed, isHistoryVersion: parsed.hashData && parsed.hashData.versionHash, - notifications: Notification && Notification.permission === "granted", + notifications: notifs, accounts: { donateURL: Cryptpad.donateURL, upgradeURL: Cryptpad.upgradeURL @@ -1605,6 +1608,7 @@ define([ }); sframeChan.on('Q_ASK_NOTIFICATION', function (data, cb) { + if (!Utils.Notify.isSupported()) { return void cb(false); } Notification.requestPermission(function (s) { cb(s === "granted"); });