From 585f9d2e4e4a28baab5cfc1c2a755efac4acda96 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 21 Nov 2017 17:19:35 +0100 Subject: [PATCH] repair broken 'clear channel' button --- www/common/common-messenger.js | 7 +++++++ www/common/sframe-common-outer.js | 7 +++++++ www/common/sframe-messenger-inner.js | 6 ++++++ www/common/sframe-protocol.js | 1 + www/contacts/messenger-ui.js | 3 ++- 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/www/common/common-messenger.js b/www/common/common-messenger.js index 5e4a714a8..406b27482 100644 --- a/www/common/common-messenger.js +++ b/www/common/common-messenger.js @@ -633,6 +633,13 @@ define([ }); }; + messenger.clearOwnedChannel = function (channel, cb) { + common.clearOwnedChannel(channel, function (e) { + if (e) { return void cb(e); } + cb(); + }); + }; + // TODO listen for changes to your friend list // emit 'update' events for clients diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 5d8fb5524..504f97f16 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -559,6 +559,13 @@ define([ }); }); }); + sframeChan.on('Q_CONTACTS_CLEAR_OWNED_CHANNEL', function (channel, cb) { + messenger.clearOwnedChannel(channel, function (e) { + cb({ + error: e, + }); + }); + }); messenger.on('message', function (message) { sframeChan.event('EV_CONTACTS_MESSAGE', message); diff --git a/www/common/sframe-messenger-inner.js b/www/common/sframe-messenger-inner.js index 9f2ed24a4..67532b015 100644 --- a/www/common/sframe-messenger-inner.js +++ b/www/common/sframe-messenger-inner.js @@ -108,6 +108,12 @@ define([], function () { }); }; + messenger.clearOwnedChannel = function (channel, cb) { + sFrameChan.query('Q_CONTACTS_CLEAR_OWNED_CHANNEL', channel, function (e) { + cb(e); + }); + }; + return messenger; }; diff --git a/www/common/sframe-protocol.js b/www/common/sframe-protocol.js index 0aedccde1..3f4e56b19 100644 --- a/www/common/sframe-protocol.js +++ b/www/common/sframe-protocol.js @@ -156,6 +156,7 @@ define({ 'Q_CONTACTS_GET_MORE_HISTORY': true, 'Q_CONTACTS_SEND_MESSAGE': true, 'Q_CONTACTS_SET_CHANNEL_HEAD': true, + 'Q_CONTACTS_CLEAR_OWNED_CHANNEL': true, // Put one or more entries to the localStore which will go in localStorage. 'EV_LOCALSTORE_PUT': true, diff --git a/www/contacts/messenger-ui.js b/www/contacts/messenger-ui.js index 0e698d8ce..988e74f43 100644 --- a/www/contacts/messenger-ui.js +++ b/www/contacts/messenger-ui.js @@ -176,7 +176,8 @@ define([ $(removeHistory).click(function () { UI.confirm(Messages.contacts_confirmRemoveHistory, function (yes) { if (!yes) { return; } - Cryptpad.clearOwnedChannel(data.channel, function (e) { + + messenger.clearOwnedChannel(data.channel, function (e) { if (e) { console.error(e); UI.alert(Messages.contacts_removeHistoryServerError);