From 6855c3e9fd065810ba0226a565e4d7aa6cb435cf Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 5 Feb 2019 16:32:49 +0100 Subject: [PATCH] Fix incorrect total size displayed for spreadsheets (#318) --- www/common/common-ui-elements.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index d682e6c74..44872e8c4 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -254,15 +254,22 @@ define([ if (common.isLoggedIn() && AppConfig.enablePinning) { // check the size of this file... - common.getFileSize(data.channel, function (e, bytes) { - if (e) { - // there was a problem with the RPC - console.error(e); - - // but we don't want to break the interface. - // continue as if there was no RPC - return void cb(void 0, $d); - } + var bytes = 0; + NThen(function (waitFor) { + var chan = [data.channel]; + if (data.rtChannel) { chan.push(data.rtChannel); } + if (data.lastVersion) { chan.push(Hash.hrefToHexChannelId(data.lastVersion)); } + chan.forEach(function (c) { + common.getFileSize(c, waitFor(function (e, _bytes) { + if (e) { + // there was a problem with the RPC + console.error(e); + } + bytes += _bytes; + })); + }); + }).nThen(function () { + if (bytes === 0) { return void cb(void 0, $d); } var KB = Util.bytesToKilobytes(bytes); var formatted = Messages._getKey('formattedKB', [KB]);