mirror of
https://github.com/element-hq/element-web
synced 2024-11-29 04:48:50 +03:00
Revert "Call MatrixClient.clearStores on logout"
This reverts commit c3d37c1ff9
.
This commit was introducing a bug where no rooms would be shown if
you want straight to /#/login and logged in (because this causes
a guest session to be created but the indexeddb store not to be
cleared, so the new login picks up the stale indexedb sync data.
This commit is contained in:
parent
df6940c5f3
commit
00ccf4bb51
2 changed files with 11 additions and 31 deletions
|
@ -237,7 +237,7 @@ function _handleRestoreFailure(e) {
|
|||
+ ' This is a once off; sorry for the inconvenience.',
|
||||
);
|
||||
|
||||
_clearStorage();
|
||||
_clearLocalStorage();
|
||||
|
||||
return q.reject(new Error(
|
||||
_t('Unable to restore previous session') + ': ' + msg,
|
||||
|
@ -258,7 +258,7 @@ function _handleRestoreFailure(e) {
|
|||
return def.promise.then((success) => {
|
||||
if (success) {
|
||||
// user clicked continue.
|
||||
_clearStorage();
|
||||
_clearLocalStorage();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -332,10 +332,6 @@ export function setLoggedIn(credentials) {
|
|||
}
|
||||
|
||||
// stop any running clients before we create a new one with these new credentials
|
||||
//
|
||||
// XXX: why do we have any running clients here? Maybe on sign-in after
|
||||
// initial use as a guest? but what about our persistent storage? we need to
|
||||
// be careful not to leak e2e data created as one user into another session.
|
||||
stopMatrixClient();
|
||||
|
||||
MatrixClientPeg.replaceUsingCreds(credentials);
|
||||
|
@ -406,19 +402,13 @@ export function startMatrixClient() {
|
|||
* a session has been logged out / ended.
|
||||
*/
|
||||
export function onLoggedOut() {
|
||||
stopMatrixClient(true);
|
||||
_clearLocalStorage();
|
||||
stopMatrixClient();
|
||||
dis.dispatch({action: 'on_logged_out'});
|
||||
}
|
||||
|
||||
function _clearStorage() {
|
||||
function _clearLocalStorage() {
|
||||
Analytics.logout();
|
||||
|
||||
const cli = MatrixClientPeg.get();
|
||||
if (cli) {
|
||||
// TODO: *really* ought to wait for the promise to complete
|
||||
cli.clearStores().done();
|
||||
}
|
||||
|
||||
if (!window.localStorage) {
|
||||
return;
|
||||
}
|
||||
|
@ -435,13 +425,9 @@ function _clearStorage() {
|
|||
}
|
||||
|
||||
/**
|
||||
* Stop all the background processes related to the current client.
|
||||
*
|
||||
* Optionally clears persistent stores.
|
||||
*
|
||||
* @param {boolean} clearStores true to clear the persistent stores.
|
||||
* Stop all the background processes related to the current client
|
||||
*/
|
||||
export function stopMatrixClient(clearStores) {
|
||||
export function stopMatrixClient() {
|
||||
Notifier.stop();
|
||||
UserActivity.stop();
|
||||
Presence.stop();
|
||||
|
@ -450,13 +436,7 @@ export function stopMatrixClient(clearStores) {
|
|||
if (cli) {
|
||||
cli.stopClient();
|
||||
cli.removeAllListeners();
|
||||
cli.store.deleteAllData();
|
||||
MatrixClientPeg.unset();
|
||||
}
|
||||
|
||||
if (clearStores) {
|
||||
// note that we have to do this *after* stopping the client, but
|
||||
// *before* clearing the MatrixClientPeg.
|
||||
_clearStorage();
|
||||
}
|
||||
|
||||
MatrixClientPeg.unset();
|
||||
}
|
||||
|
|
|
@ -292,7 +292,7 @@ module.exports = React.createClass({
|
|||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
Lifecycle.stopMatrixClient(false);
|
||||
Lifecycle.stopMatrixClient();
|
||||
dis.unregister(this.dispatcherRef);
|
||||
UDEHandler.stopListening();
|
||||
window.removeEventListener("focus", this.onFocus);
|
||||
|
@ -364,7 +364,7 @@ module.exports = React.createClass({
|
|||
// is completed in another browser, we'll be 401ed for using
|
||||
// a guest access token for a non-guest account.
|
||||
// It will be restarted in onReturnToGuestClick
|
||||
Lifecycle.stopMatrixClient(false);
|
||||
Lifecycle.stopMatrixClient();
|
||||
|
||||
this.notifyNewScreen('register');
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue