Fix ReferenceError with Notification

pull/1/head
yflory 4 years ago
parent 249483798f
commit b8780d468b

@ -97,6 +97,7 @@ define([
'/common/common-hash.js', '/common/common-hash.js',
'/common/common-util.js', '/common/common-util.js',
'/common/common-realtime.js', '/common/common-realtime.js',
'/common/notify.js',
'/common/common-constants.js', '/common/common-constants.js',
'/common/common-feedback.js', '/common/common-feedback.js',
'/common/outer/local-store.js', '/common/outer/local-store.js',
@ -105,7 +106,7 @@ define([
'/common/test.js', '/common/test.js',
'/common/userObject.js', '/common/userObject.js',
], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, _SFrameChannel, ], 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) { _Constants, _Feedback, _LocalStore, _Cache, _AppConfig, _Test, _UserObject) {
CpNfOuter = _CpNfOuter; CpNfOuter = _CpNfOuter;
Cryptpad = _Cryptpad; Cryptpad = _Cryptpad;
@ -123,6 +124,7 @@ define([
Utils.LocalStore = _LocalStore; Utils.LocalStore = _LocalStore;
Utils.Cache = _Cache; Utils.Cache = _Cache;
Utils.UserObject = _UserObject; Utils.UserObject = _UserObject;
Utils.Notify = _Notify;
Utils.currentPad = currentPad; Utils.currentPad = currentPad;
AppConfig = _AppConfig; AppConfig = _AppConfig;
Test = _Test; Test = _Test;
@ -564,6 +566,7 @@ define([
defaultTitle: defaultTitle, defaultTitle: defaultTitle,
type: cfg.type || parsed.type type: cfg.type || parsed.type
}; };
var notifs = Utils.Notify.isSupported() && Utils.Notify.hasPermission();
var additionalPriv = { var additionalPriv = {
app: parsed.type, app: parsed.type,
loggedIn: Utils.LocalStore.isLoggedIn(), loggedIn: Utils.LocalStore.isLoggedIn(),
@ -578,7 +581,7 @@ define([
isPresent: parsed.hashData && parsed.hashData.present, isPresent: parsed.hashData && parsed.hashData.present,
isEmbed: parsed.hashData && parsed.hashData.embed, isEmbed: parsed.hashData && parsed.hashData.embed,
isHistoryVersion: parsed.hashData && parsed.hashData.versionHash, isHistoryVersion: parsed.hashData && parsed.hashData.versionHash,
notifications: Notification && Notification.permission === "granted", notifications: notifs,
accounts: { accounts: {
donateURL: Cryptpad.donateURL, donateURL: Cryptpad.donateURL,
upgradeURL: Cryptpad.upgradeURL upgradeURL: Cryptpad.upgradeURL
@ -1605,6 +1608,7 @@ define([
}); });
sframeChan.on('Q_ASK_NOTIFICATION', function (data, cb) { sframeChan.on('Q_ASK_NOTIFICATION', function (data, cb) {
if (!Utils.Notify.isSupported()) { return void cb(false); }
Notification.requestPermission(function (s) { Notification.requestPermission(function (s) {
cb(s === "granted"); cb(s === "granted");
}); });

Loading…
Cancel
Save