From 32f1d1627fbdaa96122b7fd8b33903d5f12d3e43 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 3 Sep 2019 13:30:35 +0200 Subject: [PATCH] Refresh properties modal when receiving metadata updates --- www/common/common-ui-elements.js | 274 +++++++++++--------- www/common/cryptpad-common.js | 2 + www/common/outer/async-store.js | 5 +- www/common/proxy-manager.js | 2 +- www/common/sframe-chainpad-netflux-outer.js | 4 + www/common/sframe-common-outer.js | 1 - 6 files changed, 160 insertions(+), 128 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index a02fb8851..f4f5108e6 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -271,14 +271,12 @@ define([ } })); }).nThen(function (waitFor) { - console.log('koko'); // Send the command sframeChan.query('Q_SET_PAD_METADATA', { channel: channel, command: 'ADD_PENDING_OWNERS', value: toAdd }, waitFor(function (err, res) { - console.error(arguments); err = err || (res && res.error); if (err) { waitFor.abort(); @@ -286,8 +284,6 @@ define([ } // XXX })); }).nThen(function (waitFor) { - console.log('okok'); - // TODO send notifications sel.forEach(function (el) { var friend = friends[$(el).attr('data-curve')]; if (!friend) { return; } @@ -318,13 +314,17 @@ define([ return $div2; }; + var pending = false; redrawAll = function () { - $div1.empty(); - $div2.empty(); + if (pending) { return; } + pending = true; common.getPadMetadata(null, function (obj) { + pending = false; if (obj && obj.error) { return; } owners = obj.owners; pending_owners = obj.pending_owners; + $div1.empty(); + $div2.empty(); $div1.append(drawRemove(false)).append(drawRemove(true)); $div2.append(drawAdd()); }); @@ -333,6 +333,15 @@ define([ $div1.append(drawRemove(false)).append(drawRemove(true)); $div2.append(drawAdd()); + var handler = sframeChan.on('EV_RT_METADATA', function (md) { + if (!$div1.length) { + return void handler.stop(); + } + owners = md.owners; + pending_owners = md.pending_owners; + redrawAll(); + }); + // Create modal var link = h('div.cp-share-columns', [ div1, @@ -349,139 +358,158 @@ define([ return UI.dialog.customModal(link, {buttons: linkButtons}); }; var getRightsProperties = function (common, data, cb) { - var $d = $('
'); - if (!data) { return void cb(void 0, $d); } + var $div = $('
'); + if (!data) { return void cb(void 0, $div); } - $('