fix the issue with loading topics from cache

This commit is contained in:
or-else
2021-05-01 20:07:24 -07:00
parent 1537016942
commit 4a480d71cc
7 changed files with 51 additions and 29 deletions
+16 -6
View File
@@ -251,9 +251,13 @@ class TinodeWeb extends React.Component {
});
}
const token = keepLoggedIn ? LocalStorageUtil.getObject('auth-token') : undefined;
// Parse and save the hash navigation params.
const parsedNav = HashNavigation.parseUrlHash(window.location.hash);
// Read contacts from cache.
this.resetContactList();
const token = keepLoggedIn ? LocalStorageUtil.getObject('auth-token') : undefined;
if (token) {
this.setState({autoLogin: true});
@@ -385,10 +389,16 @@ class TinodeWeb extends React.Component {
}
// Topic for MessagesView selector.
if (hash.path.length > 1 && hash.path[1] != this.state.topicSelected) {
this.setState({
topicSelected: Tinode.topicType(hash.path[1]) ? hash.path[1] : null
});
const topicName = hash.path[1];
if (Tinode.topicType(topicName) && topicName != this.state.topicSelected) {
const newState = {
topicSelected: topicName
};
const acs = this.tinode.getTopicAccessMode(topicName);
if (acs) {
newState.topicSelectedAcs = acs;
}
this.setState(newState);
}
} else {
// Empty hashpath