Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 00ccf4b

Browse files
committed
Revert "Call MatrixClient.clearStores on logout"
This reverts commit c3d37c1. 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.
1 parent df6940c commit 00ccf4b

File tree

2 files changed

+11
-31
lines changed

2 files changed

+11
-31
lines changed

src/Lifecycle.js

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ function _handleRestoreFailure(e) {
237237
+ ' This is a once off; sorry for the inconvenience.',
238238
);
239239

240-
_clearStorage();
240+
_clearLocalStorage();
241241

242242
return q.reject(new Error(
243243
_t('Unable to restore previous session') + ': ' + msg,
@@ -258,7 +258,7 @@ function _handleRestoreFailure(e) {
258258
return def.promise.then((success) => {
259259
if (success) {
260260
// user clicked continue.
261-
_clearStorage();
261+
_clearLocalStorage();
262262
return false;
263263
}
264264

@@ -332,10 +332,6 @@ export function setLoggedIn(credentials) {
332332
}
333333

334334
// stop any running clients before we create a new one with these new credentials
335-
//
336-
// XXX: why do we have any running clients here? Maybe on sign-in after
337-
// initial use as a guest? but what about our persistent storage? we need to
338-
// be careful not to leak e2e data created as one user into another session.
339335
stopMatrixClient();
340336

341337
MatrixClientPeg.replaceUsingCreds(credentials);
@@ -406,19 +402,13 @@ export function startMatrixClient() {
406402
* a session has been logged out / ended.
407403
*/
408404
export function onLoggedOut() {
409-
stopMatrixClient(true);
405+
_clearLocalStorage();
406+
stopMatrixClient();
410407
dis.dispatch({action: 'on_logged_out'});
411408
}
412409

413-
function _clearStorage() {
410+
function _clearLocalStorage() {
414411
Analytics.logout();
415-
416-
const cli = MatrixClientPeg.get();
417-
if (cli) {
418-
// TODO: *really* ought to wait for the promise to complete
419-
cli.clearStores().done();
420-
}
421-
422412
if (!window.localStorage) {
423413
return;
424414
}
@@ -435,13 +425,9 @@ function _clearStorage() {
435425
}
436426

437427
/**
438-
* Stop all the background processes related to the current client.
439-
*
440-
* Optionally clears persistent stores.
441-
*
442-
* @param {boolean} clearStores true to clear the persistent stores.
428+
* Stop all the background processes related to the current client
443429
*/
444-
export function stopMatrixClient(clearStores) {
430+
export function stopMatrixClient() {
445431
Notifier.stop();
446432
UserActivity.stop();
447433
Presence.stop();
@@ -450,13 +436,7 @@ export function stopMatrixClient(clearStores) {
450436
if (cli) {
451437
cli.stopClient();
452438
cli.removeAllListeners();
439+
cli.store.deleteAllData();
440+
MatrixClientPeg.unset();
453441
}
454-
455-
if (clearStores) {
456-
// note that we have to do this *after* stopping the client, but
457-
// *before* clearing the MatrixClientPeg.
458-
_clearStorage();
459-
}
460-
461-
MatrixClientPeg.unset();
462442
}

src/components/structures/MatrixChat.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ module.exports = React.createClass({
292292
},
293293

294294
componentWillUnmount: function() {
295-
Lifecycle.stopMatrixClient(false);
295+
Lifecycle.stopMatrixClient();
296296
dis.unregister(this.dispatcherRef);
297297
UDEHandler.stopListening();
298298
window.removeEventListener("focus", this.onFocus);
@@ -364,7 +364,7 @@ module.exports = React.createClass({
364364
// is completed in another browser, we'll be 401ed for using
365365
// a guest access token for a non-guest account.
366366
// It will be restarted in onReturnToGuestClick
367-
Lifecycle.stopMatrixClient(false);
367+
Lifecycle.stopMatrixClient();
368368

369369
this.notifyNewScreen('register');
370370
break;

0 commit comments

Comments
 (0)