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); const parsedNav = HashNavigation.parseUrlHash(window.location.hash);
// Read contacts from cache.
this.resetContactList();
const token = keepLoggedIn ? LocalStorageUtil.getObject('auth-token') : undefined;
if (token) { if (token) {
this.setState({autoLogin: true}); this.setState({autoLogin: true});
@@ -385,10 +389,16 @@ class TinodeWeb extends React.Component {
} }
// Topic for MessagesView selector. // Topic for MessagesView selector.
if (hash.path.length > 1 && hash.path[1] != this.state.topicSelected) { const topicName = hash.path[1];
this.setState({ if (Tinode.topicType(topicName) && topicName != this.state.topicSelected) {
topicSelected: Tinode.topicType(hash.path[1]) ? hash.path[1] : null const newState = {
}); topicSelected: topicName
};
const acs = this.tinode.getTopicAccessMode(topicName);
if (acs) {
newState.topicSelectedAcs = acs;
}
this.setState(newState);
} }
} else { } else {
// Empty hashpath // Empty hashpath
+15 -5
View File
@@ -5007,8 +5007,9 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
}).catch(() => {}); }).catch(() => {});
} }
const token = keepLoggedIn ? _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_15__.default.getObject('auth-token') : undefined;
const parsedNav = _lib_navigation_js__WEBPACK_IMPORTED_MODULE_16__.default.parseUrlHash(window.location.hash); const parsedNav = _lib_navigation_js__WEBPACK_IMPORTED_MODULE_16__.default.parseUrlHash(window.location.hash);
this.resetContactList();
const token = keepLoggedIn ? _lib_local_storage_js__WEBPACK_IMPORTED_MODULE_15__.default.getObject('auth-token') : undefined;
if (token) { if (token) {
this.setState({ this.setState({
@@ -5154,10 +5155,19 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
console.log("Unknown sidepanel view", hash.path[0]); console.log("Unknown sidepanel view", hash.path[0]);
} }
if (hash.path.length > 1 && hash.path[1] != this.state.topicSelected) { const topicName = hash.path[1];
this.setState({
topicSelected: tinode_sdk__WEBPACK_IMPORTED_MODULE_5___default().topicType(hash.path[1]) ? hash.path[1] : null if (tinode_sdk__WEBPACK_IMPORTED_MODULE_5___default().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 { } else {
this.setState({ this.setState({
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+8 -6
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long