From 51fa6287c1cf1ab3bb23bcda91c0569159db0213 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 29 Aug 2017 11:20:02 +0200 Subject: [PATCH] Enable notifications in secure pads --- www/common/sframe-common.js | 4 ++++ www/common/sframe-protocol.js | 4 ++++ www/pad/inner.js | 2 +- www/pad/main.js | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index 59debfc32..f75720d7f 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -75,6 +75,10 @@ define([ }); }; + funcs.notify = function () { + ctx.sframeChan.event('EV_NOTIFY'); + }; + funcs.setLoginRedirect = function (cb) { ctx.sframeChan.query('Q_SET_LOGIN_REDIRECT', null, function (err) { if (cb) { cb(err); } diff --git a/www/common/sframe-protocol.js b/www/common/sframe-protocol.js index 70151e58f..f272d3743 100644 --- a/www/common/sframe-protocol.js +++ b/www/common/sframe-protocol.js @@ -78,4 +78,8 @@ define({ 'Q_SEND_FRIEND_REQUEST': true, // Up query 'Q_INCOMING_FRIEND_REQUEST': true, // Down query 'EV_FRIEND_REQUEST': true, // Down event when the request is complete + + // Set the tab notification when the content of the pad changes + 'EV_NOTIFY': true, + }); diff --git a/www/pad/inner.js b/www/pad/inner.js index eb3f77d8c..48c901d69 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -489,7 +489,7 @@ define([ // Notify only when the content has changed, not when someone has joined/left var oldSInner = stringify(JSON.parse(oldShjson)[2]); if (newSInner && newSInner !== oldSInner) { - Cryptpad.notify(); + common.notify(); } }; diff --git a/www/pad/main.js b/www/pad/main.js index f93e4b53d..91c76f7d3 100644 --- a/www/pad/main.js +++ b/www/pad/main.js @@ -151,6 +151,10 @@ define([ Cryptpad.logout(cb); }); + sframeChan.on('EV_NOTIFY', function () { + Cryptpad.notify(); + }); + sframeChan.on('Q_SET_LOGIN_REDIRECT', function (data, cb) { sessionStorage.redirectTo = window.location.href; cb();