bug fix: an extra copy of a p2p topic was sometimes created
This commit is contained in:
+20
-26
@@ -2022,7 +2022,9 @@
|
|||||||
// Unbind the previous topic from this component.
|
// Unbind the previous topic from this component.
|
||||||
if (this.state.topic) {
|
if (this.state.topic) {
|
||||||
var oldTopic = Tinode.getTopic(this.state.topic);
|
var oldTopic = Tinode.getTopic(this.state.topic);
|
||||||
oldTopic.leave(false);
|
if (oldTopic.isSubscribed()) {
|
||||||
|
oldTopic.leave(false);
|
||||||
|
}
|
||||||
oldTopic.onData = undefined;
|
oldTopic.onData = undefined;
|
||||||
oldTopic.onInfo = undefined;
|
oldTopic.onInfo = undefined;
|
||||||
oldTopic.onMetaDesc = undefined;
|
oldTopic.onMetaDesc = undefined;
|
||||||
@@ -2030,11 +2032,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (topic.isSubscribed()) {
|
if (topic.isSubscribed()) {
|
||||||
|
console.log("topic " + props.topic + " is subscribed");
|
||||||
this.handleDescChange(topic);
|
this.handleDescChange(topic);
|
||||||
topic.messages(function(msg) {
|
topic.messages(function(msg) {
|
||||||
msgs = msgs.concat(msg);
|
msgs = msgs.concat(msg);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
console.log("topic " + props.topic + " is NOT subscribed");
|
||||||
topic.subscribe({get: {desc: {}, sub: {}, data: {}}});
|
topic.subscribe({get: {desc: {}, sub: {}, data: {}}});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2054,7 +2058,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleSubsUpdated: function(uids) {
|
handleSubsUpdated: function(uids) {
|
||||||
console.log("topic subscriptions updated");
|
// console.log("topic subscriptions updated");
|
||||||
},
|
},
|
||||||
handleNewMessage: function(msg) {
|
handleNewMessage: function(msg) {
|
||||||
clearTimeout(this.readTimer);
|
clearTimeout(this.readTimer);
|
||||||
@@ -2573,35 +2577,25 @@
|
|||||||
handleNewTopicRequest: function(peerName, pub) {
|
handleNewTopicRequest: function(peerName, pub) {
|
||||||
var instance = this;
|
var instance = this;
|
||||||
|
|
||||||
// Check if user clicked on an existing connection.
|
var topic = peerName ? Tinode.newTopicWith(peerName) : Tinode.newTopic();
|
||||||
if (Tinode.getTopicType(peerName) === "p2p") {
|
var params = {get: {desc: {}, data: {}}};
|
||||||
|
if (!peerName) {
|
||||||
|
params.get.sub = {};
|
||||||
|
params.set = {desc: {public: pub}};
|
||||||
|
}
|
||||||
|
|
||||||
|
topic.subscribe(params).then(function() {
|
||||||
instance.setState({
|
instance.setState({
|
||||||
errorText: '',
|
errorText: '',
|
||||||
topicSelected: peerName,
|
topicSelected: topic.name,
|
||||||
sidePanelSelected: 'contacts',
|
sidePanelSelected: 'contacts',
|
||||||
mobilePanel: 'topic-view',
|
mobilePanel: 'topic-view',
|
||||||
showInfoPanel: false
|
showInfoPanel: false,
|
||||||
|
infoPanelShowMembers: peerName ? false : true
|
||||||
});
|
});
|
||||||
} else {
|
}).catch(function(err) {
|
||||||
var topic = peerName ? Tinode.newTopicWith(peerName) : Tinode.newTopic();
|
instance.setState({errorText: err.message});
|
||||||
var params = {get: {desc: {}, data: {}}};
|
});
|
||||||
if (!peerName) {
|
|
||||||
params.get.sub = {}; // Fetch subs for grp topics only. Subscriptions for a p2p topic are useless.
|
|
||||||
params.set = {desc: {public: pub}};
|
|
||||||
}
|
|
||||||
topic.subscribe(params).then(function() {
|
|
||||||
instance.setState({
|
|
||||||
errorText: '',
|
|
||||||
topicSelected: topic.name,
|
|
||||||
sidePanelSelected: 'contacts',
|
|
||||||
mobilePanel: 'topic-view',
|
|
||||||
showInfoPanel: true,
|
|
||||||
infoPanelShowMembers: true
|
|
||||||
});
|
|
||||||
}).catch(function(err) {
|
|
||||||
instance.setState({errorText: err.message});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
//handleManageGroupMembers: function(topicName) {
|
//handleManageGroupMembers: function(topicName) {
|
||||||
|
|||||||
Reference in New Issue
Block a user