diff --git a/www/common/common-messenger.js b/www/common/common-messenger.js index 05ebfea54..ce48c7a65 100644 --- a/www/common/common-messenger.js +++ b/www/common/common-messenger.js @@ -943,6 +943,16 @@ define([ cb(); }; + var clearOwnedChannel = function (id, cb) { + var channel = getChannel(id); + if (!channel) { return void cb({error: 'NO_CHANNEL'}); } + if (!store.rpc) { return void cb({error: 'RPC_NOT_READY'}); } + store.rpc.clearOwnedChannel(id, function (err) { + cb({error:err}); + }); + channel.messages = []; + } + network.on('disconnect', function () { emit('DISCONNECT'); }); @@ -1000,6 +1010,9 @@ define([ if (cmd === 'SET_CHANNEL_HEAD') { return void setChannelHead(data.id, data.sig, cb); } + if (cmd === 'CLEAR_OWNED_CHANNEL') { + return void clearOwnedChannel(data, cb); + } }; Object.freeze(messenger); diff --git a/www/common/messenger-ui.js b/www/common/messenger-ui.js index bd77d80ff..9c325d7b8 100644 --- a/www/common/messenger-ui.js +++ b/www/common/messenger-ui.js @@ -291,13 +291,12 @@ define([ UI.confirm(Messages.contacts_confirmRemoveHistory, function (yes) { if (!yes) { return; } - sframeChan.query('Q_CLEAR_OWNED_CHANNEL', id, function (e) { + execCommand('CLEAR_OWNED_CHANNEL', id, function (e) { if (e) { console.error(e); UI.alert(Messages.contacts_removeHistoryServerError); return; } - clearChannel(id); }); }); }); diff --git a/www/common/pinpad.js b/www/common/pinpad.js index c31062718..353b2c4fb 100644 --- a/www/common/pinpad.js +++ b/www/common/pinpad.js @@ -152,13 +152,9 @@ define([ if (typeof(channel) !== 'string' || channel.length !== 32) { return void cb('INVALID_ARGUMENTS'); } - rpc.send('CLEAR_OWNED_CHANNEL', channel, function (e, response) { + rpc.send('CLEAR_OWNED_CHANNEL', channel, function (e) { if (e) { return cb(e); } - if (response && response.length) { - cb(void 0, response[0]); - } else { - cb('INVALID_RESPONSE'); - } + cb(); }); };