preserve navigation state on page reload
This commit is contained in:
@@ -203,7 +203,9 @@ class TinodeWeb extends React.Component {
|
|||||||
// Merged results of a search query and p2p chats.
|
// Merged results of a search query and p2p chats.
|
||||||
searchableContacts: [],
|
searchableContacts: [],
|
||||||
credMethod: undefined,
|
credMethod: undefined,
|
||||||
credCode: undefined
|
credCode: undefined,
|
||||||
|
// Topic to go to after login.
|
||||||
|
requestedTopic: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +237,7 @@ class TinodeWeb extends React.Component {
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
// Initialize desktop alerts.
|
// Initialize desktop alerts.
|
||||||
if (this.state.desktopAlertsEnabled) {
|
if (this.state.desktopAlertsEnabled) {
|
||||||
initFCMessaging().then(() => {
|
this.initFCMessaging().then(() => {
|
||||||
if (this.state.desktopAlerts) {
|
if (this.state.desktopAlerts) {
|
||||||
if (!this.state.firebaseToken) {
|
if (!this.state.firebaseToken) {
|
||||||
this.togglePushToken(true);
|
this.togglePushToken(true);
|
||||||
@@ -267,6 +269,8 @@ class TinodeWeb extends React.Component {
|
|||||||
parsedNav.path[0] = '';
|
parsedNav.path[0] = '';
|
||||||
HashNavigation.navigateTo(HashNavigation.composeUrlHash(parsedNav.path, parsedNav.params));
|
HashNavigation.navigateTo(HashNavigation.composeUrlHash(parsedNav.path, parsedNav.params));
|
||||||
} else if (!parsedNav.params.token) {
|
} else if (!parsedNav.params.token) {
|
||||||
|
// No token, save possible topic name and navigating to blank state.
|
||||||
|
this.setState({requestedTopic: parsedNav.path[1]});
|
||||||
HashNavigation.navigateTo('');
|
HashNavigation.navigateTo('');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,6 +580,8 @@ class TinodeWeb extends React.Component {
|
|||||||
if (LocalStorageUtil.getObject('keep-logged-in')) {
|
if (LocalStorageUtil.getObject('keep-logged-in')) {
|
||||||
LocalStorageUtil.setObject('auth-token', this.tinode.getAuthToken());
|
LocalStorageUtil.setObject('auth-token', this.tinode.getAuthToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const goToTopic = this.state.requestedTopic;
|
||||||
// Logged in fine, subscribe to 'me' attaching callbacks from the contacts view.
|
// Logged in fine, subscribe to 'me' attaching callbacks from the contacts view.
|
||||||
const me = this.tinode.getMeTopic();
|
const me = this.tinode.getMeTopic();
|
||||||
me.onMetaDesc = this.tnMeMetaDesc;
|
me.onMetaDesc = this.tnMeMetaDesc;
|
||||||
@@ -587,6 +593,7 @@ class TinodeWeb extends React.Component {
|
|||||||
credCode: undefined,
|
credCode: undefined,
|
||||||
myUserId: this.tinode.getCurrentUserID(),
|
myUserId: this.tinode.getCurrentUserID(),
|
||||||
autoLogin: true,
|
autoLogin: true,
|
||||||
|
requestedTopic: undefined,
|
||||||
});
|
});
|
||||||
// Subscribe, fetch topic desc, the list of subscriptions. Messages are not fetched.
|
// Subscribe, fetch topic desc, the list of subscriptions. Messages are not fetched.
|
||||||
me.subscribe(
|
me.subscribe(
|
||||||
@@ -604,7 +611,11 @@ class TinodeWeb extends React.Component {
|
|||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.setState({loadSpinnerVisible: false});
|
this.setState({loadSpinnerVisible: false});
|
||||||
});
|
});
|
||||||
HashNavigation.navigateTo(HashNavigation.setUrlSidePanel(window.location.hash, 'contacts'));
|
let urlHash = HashNavigation.setUrlSidePanel(window.location.hash, 'contacts');
|
||||||
|
if (goToTopic) {
|
||||||
|
urlHash = HashNavigation.setUrlTopic(urlHash, goToTopic);
|
||||||
|
}
|
||||||
|
HashNavigation.navigateTo(urlHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
tnMeMetaDesc(desc) {
|
tnMeMetaDesc(desc) {
|
||||||
|
|||||||
+16
-4
@@ -4967,7 +4967,8 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
|||||||
searchResults: [],
|
searchResults: [],
|
||||||
searchableContacts: [],
|
searchableContacts: [],
|
||||||
credMethod: undefined,
|
credMethod: undefined,
|
||||||
credCode: undefined
|
credCode: undefined,
|
||||||
|
requestedTopic: undefined
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4995,7 +4996,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
|||||||
this.tinode.onAutoreconnectIteration = this.handleAutoreconnectIteration;
|
this.tinode.onAutoreconnectIteration = this.handleAutoreconnectIteration;
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
if (this.state.desktopAlertsEnabled) {
|
if (this.state.desktopAlertsEnabled) {
|
||||||
initFCMessaging().then(() => {
|
this.initFCMessaging().then(() => {
|
||||||
if (this.state.desktopAlerts) {
|
if (this.state.desktopAlerts) {
|
||||||
if (!this.state.firebaseToken) {
|
if (!this.state.firebaseToken) {
|
||||||
this.togglePushToken(true);
|
this.togglePushToken(true);
|
||||||
@@ -5023,6 +5024,9 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
|||||||
parsedNav.path[0] = '';
|
parsedNav.path[0] = '';
|
||||||
_lib_navigation_js__WEBPACK_IMPORTED_MODULE_16__.default.navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_16__.default.composeUrlHash(parsedNav.path, parsedNav.params));
|
_lib_navigation_js__WEBPACK_IMPORTED_MODULE_16__.default.navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_16__.default.composeUrlHash(parsedNav.path, parsedNav.params));
|
||||||
} else if (!parsedNav.params.token) {
|
} else if (!parsedNav.params.token) {
|
||||||
|
this.setState({
|
||||||
|
requestedTopic: parsedNav.path[1]
|
||||||
|
});
|
||||||
_lib_navigation_js__WEBPACK_IMPORTED_MODULE_16__.default.navigateTo('');
|
_lib_navigation_js__WEBPACK_IMPORTED_MODULE_16__.default.navigateTo('');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5364,6 +5368,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
|||||||
_lib_local_storage_js__WEBPACK_IMPORTED_MODULE_15__.default.setObject('auth-token', this.tinode.getAuthToken());
|
_lib_local_storage_js__WEBPACK_IMPORTED_MODULE_15__.default.setObject('auth-token', this.tinode.getAuthToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const goToTopic = this.state.requestedTopic;
|
||||||
const me = this.tinode.getMeTopic();
|
const me = this.tinode.getMeTopic();
|
||||||
me.onMetaDesc = this.tnMeMetaDesc;
|
me.onMetaDesc = this.tnMeMetaDesc;
|
||||||
me.onContactUpdate = this.tnMeContactUpdate;
|
me.onContactUpdate = this.tnMeContactUpdate;
|
||||||
@@ -5373,7 +5378,8 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
|||||||
credMethod: undefined,
|
credMethod: undefined,
|
||||||
credCode: undefined,
|
credCode: undefined,
|
||||||
myUserId: this.tinode.getCurrentUserID(),
|
myUserId: this.tinode.getCurrentUserID(),
|
||||||
autoLogin: true
|
autoLogin: true,
|
||||||
|
requestedTopic: undefined
|
||||||
});
|
});
|
||||||
me.subscribe(me.startMetaQuery().withLaterSub().withDesc().withTags().withCred().build()).catch(err => {
|
me.subscribe(me.startMetaQuery().withLaterSub().withDesc().withTags().withCred().build()).catch(err => {
|
||||||
this.tinode.disconnect();
|
this.tinode.disconnect();
|
||||||
@@ -5385,7 +5391,13 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
|||||||
loadSpinnerVisible: false
|
loadSpinnerVisible: false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
_lib_navigation_js__WEBPACK_IMPORTED_MODULE_16__.default.navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_16__.default.setUrlSidePanel(window.location.hash, 'contacts'));
|
let urlHash = _lib_navigation_js__WEBPACK_IMPORTED_MODULE_16__.default.setUrlSidePanel(window.location.hash, 'contacts');
|
||||||
|
|
||||||
|
if (goToTopic) {
|
||||||
|
urlHash = _lib_navigation_js__WEBPACK_IMPORTED_MODULE_16__.default.setUrlTopic(urlHash, goToTopic);
|
||||||
|
}
|
||||||
|
|
||||||
|
_lib_navigation_js__WEBPACK_IMPORTED_MODULE_16__.default.navigateTo(urlHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
tnMeMetaDesc(desc) {
|
tnMeMetaDesc(desc) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user