From df586a223c1dd372a799cf4f8e0f872de4c0b1e7 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 9 Jun 2017 15:31:43 +0200 Subject: [PATCH] update limits, usage, plan, and note whenever they are checked --- www/common/cryptpad-common.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 36fe85515..7cd035ca8 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -30,7 +30,9 @@ define([ Clipboard: Clipboard, donateURL: 'https://accounts.cryptpad.fr/#/donate?on=' + origin, upgradeURL: 'https://accounts.cryptpad.fr/#/?on=' + origin, - account: {}, + account: { + usage: 0, + }, }; // constants @@ -744,7 +746,11 @@ define([ common.getPinnedUsage = function (cb) { if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); } - rpc.getFileListSize(cb); + + rpc.getFileListSize(function (err, bytes) { + common.account.usage = typeof(bytes) === 'number'? bytes: 0; + cb(err, bytes); + }); }; common.getFileSize = function (href, cb) { @@ -759,6 +765,9 @@ define([ if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); } rpc.updatePinLimits(function (e, limit, plan, note) { if (e) { return cb(e); } + common.account.limit = limit; + common.account.plan = plan; + common.account.note = note; cb(e, limit, plan, note); }); }; @@ -767,6 +776,9 @@ define([ 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); }); };