diff --git a/rpc.js b/rpc.js index bb9e27194..d8bbce9dd 100644 --- a/rpc.js +++ b/rpc.js @@ -497,7 +497,8 @@ var updateLimits = function (config, publicKey, cb) { var l; if (publicKey) { var limit = limits[publicKey]; - l = limit && typeof limit.limit === "number" ? limit.limit : DEFAULT_LIMIT; + l = limit && typeof limit.limit === "number" ? + [limit.limit, limit.plan] : [DEFAULT_LIMIT, '']; } cb(void 0, l); } catch (e) { @@ -519,7 +520,7 @@ var getLimit = function (publicKey, cb) { var limit = limits[unescapedKey]; var toSend = limit && typeof(limit.limit) === "number"? - limit.limit : DEFAULT_LIMIT; + [limit.limit, limit.plan] : [DEFAULT_LIMIT, '']; cb(void 0, toSend); }; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index b0c8477ba..4472dde7b 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -744,28 +744,28 @@ define([ common.updatePinLimit = function (cb) { if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); } - rpc.updatePinLimits(function (e, limit) { + rpc.updatePinLimits(function (e, limit, plan) { if (e) { return cb(e); } var MB = common.bytesToMegabytes(limit); - cb(e, MB); + cb(e, MB, plan); }); }; common.getPinLimit = function (cb) { if (!pinsReady()) { return void cb('[RPC_NOT_READY]'); } - rpc.getLimit(function (e, limit) { + rpc.getLimit(function (e, limit, plan) { if (e) { return cb(e); } var MB = common.bytesToMegabytes(limit); - cb(void 0, MB); + cb(void 0, MB, plan); }); }; common.isOverPinLimit = function (cb) { if (!common.isLoggedIn() || !AppConfig.enablePinLimit) { return void cb(null, false); } var usage; - var andThen = function (e, limit) { + var andThen = function (e, limit, plan) { if (e) { return void cb(e); } - var data = {usage: usage, limit: limit}; + var data = {usage: usage, limit: limit, plan: plan}; if (usage > limit) { return void cb (null, true, data); } @@ -780,7 +780,7 @@ define([ }; var LIMIT_REFRESH_RATE = 30000; // milliseconds - common.createUsageBar = function (cb) { + common.createUsageBar = function (cb, alwaysDisplayUpgrade) { var todo = function (err, state, data) { var $container = $('', {'class':'limit-container'}); if (!data) { @@ -796,10 +796,10 @@ define([ var width = Math.floor(Math.min(quota, 1)*200); // the bar is 200px width var $usage = $('', {'class': 'usage'}).css('width', width+'px'); - if (quota >= 0.8) { + if ((quota >= 0.8 || alwaysDisplayUpgrade) && data.plan !== "power") { var origin = encodeURIComponent(window.location.origin); var $upgradeLink = $('', { - href: "https://account.cryptpad.fr/#!on=" + origin, + href: "https://accounts.cryptpad.fr/#!on=" + origin, rel: "noreferrer noopener", target: "_blank", }).appendTo($container); diff --git a/www/common/pinpad.js b/www/common/pinpad.js index a7c5c72ee..5fe0b2b8e 100644 --- a/www/common/pinpad.js +++ b/www/common/pinpad.js @@ -126,7 +126,7 @@ define([ rpc.send('UPDATE_LIMITS', undefined, function (e, response) { if (e) { return void cb(e); } if (response && response.length && typeof(response[0]) === "number") { - cb (void 0, response); + cb (void 0, response[0], response[1]); } else { cb('INVALID_RESPONSE'); } @@ -137,7 +137,7 @@ define([ rpc.send('GET_LIMIT', undefined, function (e, response) { if (e) { return void cb(e); } if (response && response.length && typeof(response[0]) === "number") { - cb (void 0, response[0]); + cb (void 0, response[0], response[1]); } else { cb('INVALID_RESPONSE'); } diff --git a/www/settings/main.js b/www/settings/main.js index dd3f59b4e..d6791f4e0 100644 --- a/www/settings/main.js +++ b/www/settings/main.js @@ -60,7 +60,6 @@ define([ $div.append('
').append($pubLabel).append($pubKey); } - return $div; }; @@ -234,7 +233,7 @@ define([ $div.find('.limit-container').remove(); $bar.find('.upgrade').addClass('btn btn-success'); $div.append($bar); - }); + }, true); return $div; };