From eb3ccf7b1e71942fd02f7b8d1a494aa2a5de67d3 Mon Sep 17 00:00:00 2001 From: or-else Date: Wed, 16 May 2018 11:36:54 -0700 Subject: [PATCH] bug fix: crashes when switching topics with open --- index.html | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/index.html b/index.html index d75aefd1..d5cedf33 100644 --- a/index.html +++ b/index.html @@ -2501,6 +2501,7 @@ var InfoView = React.createClass({ getInitialState: function() { return { + topic: null, owner: false, admin: false, sharer: false, @@ -2539,24 +2540,23 @@ return; } - this.previousMetaDesc = topic.onMetaDesc; - topic.onMetaDesc = this.onMetaDesc; + if (this.previousMetaDesc != topic.onMetaDesc) { + this.previousMetaDesc = topic.onMetaDesc; + topic.onMetaDesc = this.onMetaDesc; - this.previousSubsUpdated = topic.onSubsUpdated; - topic.onSubsUpdated = this.onSubsUpdated; + this.previousSubsUpdated = topic.onSubsUpdated; + topic.onSubsUpdated = this.onSubsUpdated; - if (topic.getType() === "grp") { - this.previousTagsUpdated = topic.onTagsUpdated; - topic.onTagsUpdated = this.onTagsUpdated; - } else { - this.previousTagsUpdated = undefined; + if (topic.getType() === "grp") { + this.previousTagsUpdated = topic.onTagsUpdated; + topic.onTagsUpdated = this.onTagsUpdated; + } else { + this.previousTagsUpdated = undefined; + } } - this.resetInfoView(topic, props, true); - }, - - resetInfoView: function(topic, props, forced) { - if (forced || this.props.topic != props.topic) { + if (this.state.topic != props.topic) { + this.setState({topic: props.topic}); this.resetDesc(topic, props); this.resetSubs(topic, props); @@ -2571,17 +2571,14 @@ if (!topic) { return; } + this.setState({topic: null}); topic.onMetaDesc = this.previousMetaDesc; topic.onSubsUpdated = this.previousSubsUpdated; topic.onTagsUpdated = this.previousTagsUpdated; }, componentWillReceiveProps: function(nextProps) { - var topic = Tinode.getTopic(nextProps.topic); - if (!topic) { - return; - } - this.resetInfoView(topic, nextProps); + this.initInfoView(nextProps); }, resetSubs: function(topic, props) {