From 140c6f37768a84af880d1a99cbaa61408c3827de Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 21 Aug 2017 12:24:33 +0200 Subject: [PATCH] Add limit warning in pad2 --- www/common/cryptpad-common.js | 1 + www/common/sframe-common.js | 6 ++++++ www/common/sframe-protocol.js | 5 +++++ www/common/toolbar3.js | 2 +- www/pad2/main.js | 2 +- www/pad2/outer.js | 10 ++++++++++ 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index b3eb1cec3..0d41543d9 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -1314,6 +1314,7 @@ define([ 'image/jpg', 'image/gif', ]; + // SFRAME: copied to sframe-common-interface.js common.displayAvatar = function ($container, href, name, cb) { var MutationObserver = window.MutationObserver; var displayDefault = function () { diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index 8116cd39c..af7058da1 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -71,6 +71,12 @@ define([ }); }; + funcs.isOverPinLimit = function (cb) { + ctx.sframeChan.query('Q_GET_PIN_LIMIT_STATUS', null, function (err, data) { + cb(data.error, data.overLimit, data.limits); + }); + }; + /* funcs.storeLinkToClipboard = function (readOnly, cb) { ctx.sframeChan.query('Q_STORE_LINK_TO_CLIPBOARD', readOnly, function (err) { if (cb) { cb(err); } diff --git a/www/common/sframe-protocol.js b/www/common/sframe-protocol.js index e7f7ec997..7939e72af 100644 --- a/www/common/sframe-protocol.js +++ b/www/common/sframe-protocol.js @@ -57,4 +57,9 @@ define({ // Use anonymous rpc from inside the iframe (for avatars & pin usage) 'Q_ANON_RPC_MESSAGE': true, + + // Check the pin limit to determine if we can store the pad in the drive or if we should + // display a warning + 'Q_GET_PIN_LIMIT_STATUS': true, + }); diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index c3edd56a9..902ecee80 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -698,7 +698,7 @@ define([ }); } }; - Cryptpad.isOverPinLimit(todo); + Common.isOverPinLimit(todo); return $limit; }; diff --git a/www/pad2/main.js b/www/pad2/main.js index fe8fbf603..c21e11fa4 100644 --- a/www/pad2/main.js +++ b/www/pad2/main.js @@ -471,7 +471,7 @@ define([ var titleCfg = { getHeadingText: getHeadingText }; Title = common.createTitle(titleCfg, realtimeOptions.onLocal, common, cpNfInner.metadataMgr); var configTb = { - displayed: ['userlist', 'title', 'useradmin', 'spinner', 'newpad', 'share'], + displayed: ['userlist', 'title', 'useradmin', 'spinner', 'newpad', 'share', 'limit'], title: Title.getTitleConfig(), metadataMgr: cpNfInner.metadataMgr, readOnly: readOnly, diff --git a/www/pad2/outer.js b/www/pad2/outer.js index 032e8e7ac..bd47490f3 100644 --- a/www/pad2/outer.js +++ b/www/pad2/outer.js @@ -118,6 +118,16 @@ define([ cb(); }); + sframeChan.on('Q_GET_PIN_LIMIT_STATUS', function (data, cb) { + Cryptpad.isOverPinLimit(function (e, overLimit, limits) { + cb({ + error: e, + overLimit: overLimit, + limits: limits + }); + }); + }); + CpNfOuter.start({ sframeChan: sframeChan, channel: secret.channel,