@@ -237,7 +237,7 @@ function _handleRestoreFailure(e) {
237
237
+ ' This is a once off; sorry for the inconvenience.' ,
238
238
) ;
239
239
240
- _clearStorage ( ) ;
240
+ _clearLocalStorage ( ) ;
241
241
242
242
return q . reject ( new Error (
243
243
_t ( 'Unable to restore previous session' ) + ': ' + msg ,
@@ -258,7 +258,7 @@ function _handleRestoreFailure(e) {
258
258
return def . promise . then ( ( success ) => {
259
259
if ( success ) {
260
260
// user clicked continue.
261
- _clearStorage ( ) ;
261
+ _clearLocalStorage ( ) ;
262
262
return false ;
263
263
}
264
264
@@ -332,10 +332,6 @@ export function setLoggedIn(credentials) {
332
332
}
333
333
334
334
// 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.
339
335
stopMatrixClient ( ) ;
340
336
341
337
MatrixClientPeg . replaceUsingCreds ( credentials ) ;
@@ -406,19 +402,13 @@ export function startMatrixClient() {
406
402
* a session has been logged out / ended.
407
403
*/
408
404
export function onLoggedOut ( ) {
409
- stopMatrixClient ( true ) ;
405
+ _clearLocalStorage ( ) ;
406
+ stopMatrixClient ( ) ;
410
407
dis . dispatch ( { action : 'on_logged_out' } ) ;
411
408
}
412
409
413
- function _clearStorage ( ) {
410
+ function _clearLocalStorage ( ) {
414
411
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
-
422
412
if ( ! window . localStorage ) {
423
413
return ;
424
414
}
@@ -435,13 +425,9 @@ function _clearStorage() {
435
425
}
436
426
437
427
/**
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
443
429
*/
444
- export function stopMatrixClient ( clearStores ) {
430
+ export function stopMatrixClient ( ) {
445
431
Notifier . stop ( ) ;
446
432
UserActivity . stop ( ) ;
447
433
Presence . stop ( ) ;
@@ -450,13 +436,7 @@ export function stopMatrixClient(clearStores) {
450
436
if ( cli ) {
451
437
cli . stopClient ( ) ;
452
438
cli . removeAllListeners ( ) ;
439
+ cli . store . deleteAllData ( ) ;
440
+ MatrixClientPeg . unset ( ) ;
453
441
}
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 ( ) ;
462
442
}
0 commit comments