From c583819ccf8b5c99175e5ad711302544b4dd7ed8 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Mon, 12 Nov 2018 11:34:28 +1100 Subject: [PATCH] Fixed view layouts after deleting a conversation. --- js/background.js | 9 ++++++++- js/models/messages.js | 4 +--- js/views/inbox_view.js | 18 ++++++++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/js/background.js b/js/background.js index c7d9d0834..b2a7ad9dd 100644 --- a/js/background.js +++ b/js/background.js @@ -585,6 +585,13 @@ } }); + Whisper.events.on('deleteConversation', async conversation => { + await conversation.destroyMessages(); + await window.Signal.Data.removeConversation(conversation.id, { + Conversation: Whisper.Conversation, + }); + }); + Whisper.Notifications.on('click', conversation => { window.showWindow(); if (conversation) { @@ -602,7 +609,7 @@ if (messageReceiver) { messageReceiver.onFriendRequestUpdate(pubKey, message); } - }) + }); Whisper.events.on('showFriendRequest', friendRequest => { if (appView) { diff --git a/js/models/messages.js b/js/models/messages.js index 6f1444403..64e9139c0 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -329,9 +329,7 @@ }; const onDelete = async () => { - await window.Signal.Data.removeConversation(conversation.id, { - Conversation: Whisper.Conversation, - }) + window.Whisper.events.trigger('deleteConversation', conversation); }; return { diff --git a/js/views/inbox_view.js b/js/views/inbox_view.js index 72abb36f0..294b33b86 100644 --- a/js/views/inbox_view.js +++ b/js/views/inbox_view.js @@ -37,6 +37,12 @@ } conversation.trigger('opened'); }, + close(conversation) { + const $el = this.$(`#conversation-${conversation.cid}`); + if ($el && $el.length > 0) { + $el.remove(); + } + } }); Whisper.FontSizeView = Whisper.View.extend({ @@ -138,10 +144,12 @@ 'add change:timestamp change:name change:number', this.inboxListView.updateLocation ); - this.inboxListView.listenTo( + + // Listen to any conversation remove + this.listenTo( inboxCollection, 'remove', - this.inboxListView.removeItem + this.closeConversation, ); this.searchView = new Whisper.ConversationSearchView({ @@ -274,6 +282,12 @@ this.focusConversation(); } }, + closeConversation(conversation) { + if (conversation) { + this.inboxListView.removeItem(conversation); + this.conversation_stack.close(conversation); + } + }, closeRecording(e) { if (e && this.$(e.target).closest('.capture-audio').length > 0) { return;