From d2dcd6c23d537d383ae75f1660cf8afb8f4533b7 Mon Sep 17 00:00:00 2001 From: Beaudan Brown Date: Wed, 4 Sep 2019 16:44:49 +1000 Subject: [PATCH] Stop polling when you leave the public chat, clear up a bit --- js/models/conversations.js | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 84ab4c509..22df92046 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -1378,7 +1378,7 @@ options.messageType = message.get('type'); options.isPublic = this.isPublic(); if (options.isPublic) { - options.publicSendData = await this.getPublicSendData(); + options.publicSendData = this.getPublicSendData(); } const groupNumbers = this.getRecipients(); @@ -2070,7 +2070,7 @@ conversationId: this.get('id'), }; }, - async getPublicSendData() { + getPublicSendData() { const serverAPI = lokiPublicChatAPI.findOrCreateServer( this.get('server') ); @@ -2312,27 +2312,24 @@ }, deleteContact() { - if (this.isPublic()) { - Whisper.events.trigger('showConfirmationDialog', { - message: i18n('deletePublicChannelConfirmation'), - onOk: () => ConversationController.deleteContact(this.id), - }); - } else { - Whisper.events.trigger('showConfirmationDialog', { - message: i18n('deleteContactConfirmation'), - onOk: () => ConversationController.deleteContact(this.id), - }); - } + const message = this.isPublic() + ? i18n('deletePublicChannelConfirmation') + : i18n('deleteContactConfirmation'); + + Whisper.events.trigger('showConfirmationDialog', { + message, + onOk: () => { + ConversationController.deleteContact(this.id); + if (this.isPublic()) { + const channelAPI = this.getPublicSendData(); + channelAPI.stop(); + } + }, + }); }, async deletePublicMessage(message) { - const serverAPI = lokiPublicChatAPI.findOrCreateServer( - this.get('server') - ); - const channelAPI = serverAPI.findOrCreateChannel( - this.get('channelId'), - this.id - ); + const channelAPI = this.getPublicSendData(); const success = await channelAPI.deleteMessage(message.getServerId()); if (success) { this.removeMessage(message.id);