ConversationStack: Unset lastConversation on model unload
This commit is contained in:

committed by
Ken Powers

parent
86864279b2
commit
05439c6cd6
@@ -29,6 +29,9 @@
|
||||
model: conversation,
|
||||
window: this.model.window,
|
||||
});
|
||||
this.listenTo(conversation, 'unload', () =>
|
||||
this.onUnload(conversation)
|
||||
);
|
||||
view.$el.appendTo(this.el);
|
||||
|
||||
if (this.lastConversation) {
|
||||
@@ -36,6 +39,8 @@
|
||||
'unload',
|
||||
'opened another conversation'
|
||||
);
|
||||
this.stopListening(this.lastConversation);
|
||||
this.lastConversation = null;
|
||||
}
|
||||
|
||||
this.lastConversation = conversation;
|
||||
@@ -47,8 +52,9 @@
|
||||
// Make sure poppers are positioned properly
|
||||
window.dispatchEvent(new Event('resize'));
|
||||
},
|
||||
onUnload(conversationId) {
|
||||
if (this.lastConversation.id === conversationId) {
|
||||
onUnload(conversation) {
|
||||
if (this.lastConversation === conversation) {
|
||||
this.stopListening(this.lastConversation);
|
||||
this.lastConversation = null;
|
||||
}
|
||||
},
|
||||
@@ -80,9 +86,6 @@
|
||||
el: this.$('.conversation-stack'),
|
||||
model: { window: options.window },
|
||||
});
|
||||
Whisper.events.on('unloadConversation', conversationId => {
|
||||
this.conversation_stack.onUnload(conversationId);
|
||||
});
|
||||
|
||||
if (!options.initialLoadComplete) {
|
||||
this.appLoadingScreen = new Whisper.AppLoadingScreen();
|
||||
|
Reference in New Issue
Block a user