From c6dbe3830edb5f46a251abf132bbc83d703197c6 Mon Sep 17 00:00:00 2001 From: or-else Date: Thu, 3 May 2018 13:35:33 -0700 Subject: [PATCH] bug fix: callback to a stale ContactsView --- index.html | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index c44b5822..d44518ef 100644 --- a/index.html +++ b/index.html @@ -1870,12 +1870,17 @@ contactList: this.prepareContactList() }; }, + componentWillMount: function() { var me = Tinode.getMeTopic(); - if (!me.onContactUpdate) { - me.onContactUpdate = this.tnMeContactUpdate; - me.onSubsUpdated = this.tnMeSubsUpdated; - } + me.onContactUpdate = this.tnMeContactUpdate; + me.onSubsUpdated = this.tnMeSubsUpdated; + }, + + componentWillUnmount: function() { + var me = Tinode.getMeTopic(); + me.onContactUpdate = undefined; + me.onSubsUpdated = undefined; }, componentWillReceiveProps: function(nextProps) { @@ -1917,7 +1922,6 @@ // Explicitly ignoring "recv" -- it causes no visible updates to contact list. } else if (what === "gone" || what === "unsub") { // Topic deleted or user unsubscribed. Remove topic from view. - // If the currently selected topic is gone, clear the selection. if (this.props.topicSelected === cont.topic) { this.props.onTopicSelected(null); @@ -1963,7 +1967,6 @@ return b.touched - a.touched; }); updateFavicon(totalUnread > 0); - return contacts; },