From fce0a37f50ee7f704295592c176ac87d17711a26 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 26 Jun 2017 17:32:31 +0200 Subject: [PATCH 1/3] cache pin data once retrieved from the server --- www/common/cryptpad-common.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 1c7e050ed..47b549bb8 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -32,9 +32,7 @@ define([ Clipboard: Clipboard, donateURL: 'https://accounts.cryptpad.fr/#/donate?on=' + origin, upgradeURL: 'https://accounts.cryptpad.fr/#/?on=' + origin, - account: { - usage: 0, - }, + account: {}, }; // constants @@ -759,7 +757,9 @@ define([ if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); } rpc.getFileListSize(function (err, bytes) { - common.account.usage = typeof(bytes) === 'number'? bytes: 0; + if (typeof(bytes) === 'number') { + common.account.usage = bytes; + } cb(err, bytes); }); }; @@ -785,13 +785,21 @@ define([ common.getPinLimit = function (cb) { if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); } - rpc.getLimit(function (e, limit, plan, note) { - if (e) { return cb(e); } - common.account.limit = limit; - common.account.plan = plan; - common.account.note = note; - cb(void 0, limit, plan, note); - }); + + var account = common.account; + if (typeof(account.limit) !== 'number' || + typeof(account.plan) !== 'string' || + typeof(account.note) !== 'string') { + return void rpc.getLimit(function (e, limit, plan, note) { + if (e) { return cb(e); } + common.account.limit = limit; + common.account.plan = plan; + common.account.note = note; + cb(void 0, limit, plan, note); + }); + } + + cb(void 0, account.limit, account.plan, account.note); }; common.isOverPinLimit = function (cb) { From 9195c0cd12d691a462811a0790c0ffd59187a246 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 26 Jun 2017 18:13:06 +0200 Subject: [PATCH 2/3] is isOverPinLimit in toolbar --- www/common/toolbar2.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/www/common/toolbar2.js b/www/common/toolbar2.js index 9b89e55ce..7378c13e2 100644 --- a/www/common/toolbar2.js +++ b/www/common/toolbar2.js @@ -664,13 +664,17 @@ define([ }); } }; - var limit = Cryptpad.account.limit; - var usage = Cryptpad.account.usage; - if (typeof(limit) !== 'number' || typeof(usage) !== 'number') { - todo("invalid types"); - } else if (Cryptpad.isLoggedIn() && usage >= limit) { - todo(void 0, true); - } else { todo(void 0, false); } + + Cryptpad.isOverPinLimit(function (e, isOver, data) { + var limit = data.limit; + var usage = data.usage; + if (typeof(limit) !== 'number' || typeof(usage) !== 'number') { + todo("invalid types"); + } else if (Cryptpad.isLoggedIn() && usage >= limit) { + todo(void 0, true); + } else { todo(void 0, false); } + }); + return $limit; }; From 7b3714603445d483fb544e6606023d8fba000d18 Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 26 Jun 2017 18:32:29 +0200 Subject: [PATCH 3/3] don't let spacebar keyups propagate outside of the title --- www/common/toolbar2.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/www/common/toolbar2.js b/www/common/toolbar2.js index 7378c13e2..001eac3b6 100644 --- a/www/common/toolbar2.js +++ b/www/common/toolbar2.js @@ -492,6 +492,8 @@ define([ $pencilIcon.show(); $saveIcon.hide(); //$pencilIcon.css('display', ''); + } else if (e.which === 32) { + e.stopPropagation(); } }); $saveIcon.click(save);