yet even more bug fixes in navigation

This commit is contained in:
or-else
2018-04-26 14:13:18 -07:00
parent c110c4bb5e
commit ff67a6d3d2
+38 -30
View File
@@ -652,11 +652,11 @@
};
},
componentWillReceiveProps: function(newProps) {
componentWillReceiveProps: function(nextProps) {
// If text has changed while in read mode, update text and discard changes.
// Ignore update if in edit mode.
if (this.props.text != newProps.text && !this.state.active) {
this.setState({text: newProps.text || ""});
if (this.props.text != nextProps.text && !this.state.active) {
this.setState({text: nextProps.text || ""});
}
},
@@ -904,12 +904,12 @@
};
},
componentWillReceiveProps: function(newProps) {
componentWillReceiveProps: function(nextProps) {
this.setState({
sortedChips: this.sortChips(newProps.chips, newProps.required),
chipIndex: this.indexChips(newProps.chips)
sortedChips: this.sortChips(nextProps.chips, nextProps.required),
chipIndex: this.indexChips(nextProps.chips)
});
if (newProps.chips.length > this.props.chips.length) {
if (nextProps.chips.length > this.props.chips.length) {
// Chip added: clear input.
this.setState({input: ''});
}
@@ -1485,8 +1485,8 @@
};
},
componentWillReceiveProps: function(newProps) {
this.setState({show: !(!newProps.level)});
componentWillReceiveProps: function(nextProps) {
this.setState({show: !(!nextProps.level)});
},
hide: function() {
@@ -1855,8 +1855,7 @@
var ContactsView = React.createClass({
getInitialState: function() {
return {
contactList: this.prepareContactList(),
initialLoadComplete: false
contactList: this.prepareContactList()
};
},
componentWillMount: function() {
@@ -1866,13 +1865,27 @@
me.onSubsUpdated = this.tnMeSubsUpdated;
}
},
componentWillReceiveProps: function(nextProps) {
if (this.props.topicSelected != nextProps.topicSelected) {
// If topicSelecetd is changed externally, update the
// topic with online status and access mode.
for (var i=0;i<this.state.contactList.length;i++) {
var c = this.state.contactList[i];
if (c.topic == nextProps.topicSelected) {
nextProps.onOnlineChange(c.online);
nextProps.onAcsChange(c.acs);
break;
}
}
}
},
// Reactions to updates to the contact list.
tnMeContactUpdate: function(what, cont) {
console.log("presence", this.props.topicSelected, cont.topic, what);
if (what == "on" || what == "off") {
this.resetContactList();
if (this.props.topicSelected === cont.topic) {
console.log("Online/offline", cont.topic, what);
if (this.props.topicSelected == cont.topic) {
this.props.onOnlineChange(what === "on");
}
} else if (what === "read") {
@@ -1907,10 +1920,10 @@
}
} else {
// TODO(gene): handle other types of notifications:
// * ua -- user agent changes (may display a pictogram for mobile/desktop)
// * upd -- topic 'public' updated
// * del -- messages deleted (hard or soft) -- reset pill counter
console.log("changed (not updating for it): " + what + " in: " + cont.topic);
// * ua -- user agent changes (maybe display a pictogram for mobile/desktop).
// * upd -- topic 'public' updated, issue getMeta().
// * del -- messages deleted (hard or soft) -- reset pill counter.
console.log("Unsupported (yet) presence update:" + what + " in: " + cont.topic);
}
},
@@ -1943,10 +1956,7 @@
},
resetContactList: function() {
if (!this.state.initialLoadComplete) {
console.log("update winodow.location.hash now!!!");
}
this.setState({contactList: this.prepareContactList(), initialLoadComplete: true});
this.setState({contactList: this.prepareContactList()});
},
render: function() {
@@ -2544,12 +2554,12 @@
topic.onTagsUpdated = this.previousTagsUpdated;
},
componentWillReceiveProps: function(props) {
var topic = Tinode.getTopic(props.topic);
componentWillReceiveProps: function(nextProps) {
var topic = Tinode.getTopic(nextProps.topic);
if (!topic) {
return;
}
this.resetInfoView(topic, props);
this.resetInfoView(topic, nextProps);
},
resetSubs: function(topic, props) {
@@ -3848,14 +3858,11 @@
}
}
// Topic for MessagesView selector.
console.log("hashchange", window.location.hash, hash.path);
if (hash.path.length > 1) {
var tp = Tinode.getTopicType(hash.path[1]);
if (tp) {
console.log("setting topicSelected to", hash.path[1]);
this.setState({topicSelected: hash.path[1]});
} else {
console.log("setting topicSelected to null");
this.setState({topicSelected: null});
}
}
@@ -4087,7 +4094,9 @@
},
handleTopicSelectedOnline: function(online) {
this.setState({topicSelectedOnline: online});
if (typeof online == 'boolean') {
this.setState({topicSelectedOnline: online});
}
},
// Permissions of a currently selected topic have been updated by server.
handleTopicSelectedAcs: function(acs) {
@@ -4191,7 +4200,6 @@
},
// Create of a new topic. New P2P topic requires peer's name.
handleNewTopicRequest: function(peerName, pub, priv, tags) {
console.log("handleNewTopicRequest");
var instance = this;
var topic = peerName ? Tinode.newTopicWith(peerName) : Tinode.newTopic();
var query = topic.startMetaQuery().withDesc().withSub().withData();