mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-04 13:15:58 +03:00
Merge pull request #930 from matrix-org/luke/new-guest-access-reset-stores-on-logged-out
Reset store state when logging out
This commit is contained in:
commit
44f479c38b
3 changed files with 27 additions and 6 deletions
|
@ -16,6 +16,10 @@ limitations under the License.
|
||||||
import dis from '../dispatcher';
|
import dis from '../dispatcher';
|
||||||
import {Store} from 'flux/utils';
|
import {Store} from 'flux/utils';
|
||||||
|
|
||||||
|
const INITIAL_STATE = {
|
||||||
|
deferred_action: null,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class for storing application state to do with login/registration. This is a simple
|
* A class for storing application state to do with login/registration. This is a simple
|
||||||
* flux store that listens for actions and updates its state accordingly, informing any
|
* flux store that listens for actions and updates its state accordingly, informing any
|
||||||
|
@ -26,9 +30,7 @@ class LifecycleStore extends Store {
|
||||||
super(dis);
|
super(dis);
|
||||||
|
|
||||||
// Initialise state
|
// Initialise state
|
||||||
this._state = {
|
this._state = INITIAL_STATE;
|
||||||
deferred_action: null,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_setState(newState) {
|
_setState(newState) {
|
||||||
|
@ -54,8 +56,15 @@ class LifecycleStore extends Store {
|
||||||
});
|
});
|
||||||
dis.dispatch(deferredAction);
|
dis.dispatch(deferredAction);
|
||||||
break;
|
break;
|
||||||
|
case 'on_logged_out':
|
||||||
|
this.reset();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
this._state = Object.assign({}, INITIAL_STATE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let singletonLifecycleStore = null;
|
let singletonLifecycleStore = null;
|
||||||
|
|
|
@ -73,6 +73,9 @@ class RoomViewStore extends Store {
|
||||||
case 'join_room':
|
case 'join_room':
|
||||||
this._joinRoom(payload);
|
this._joinRoom(payload);
|
||||||
break;
|
break;
|
||||||
|
case 'on_logged_out':
|
||||||
|
this.reset();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,10 @@ limitations under the License.
|
||||||
import dis from '../dispatcher';
|
import dis from '../dispatcher';
|
||||||
import {Store} from 'flux/utils';
|
import {Store} from 'flux/utils';
|
||||||
|
|
||||||
|
const INITIAL_STATE = {
|
||||||
|
cachedPassword: localStorage.getItem('mx_pass'),
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class for storing application state to do with the session. This is a simple flux
|
* A class for storing application state to do with the session. This is a simple flux
|
||||||
* store that listens for actions and updates its state accordingly, informing any
|
* store that listens for actions and updates its state accordingly, informing any
|
||||||
|
@ -33,9 +37,7 @@ class SessionStore extends Store {
|
||||||
super(dis);
|
super(dis);
|
||||||
|
|
||||||
// Initialise state
|
// Initialise state
|
||||||
this._state = {
|
this._state = INITIAL_STATE;
|
||||||
cachedPassword: localStorage.getItem('mx_pass'),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_update() {
|
_update() {
|
||||||
|
@ -66,9 +68,16 @@ class SessionStore extends Store {
|
||||||
cachedPassword: null,
|
cachedPassword: null,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case 'on_logged_out':
|
||||||
|
this.reset();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
this._state = Object.assign({}, INITIAL_STATE);
|
||||||
|
}
|
||||||
|
|
||||||
getCachedPassword() {
|
getCachedPassword() {
|
||||||
return this._state.cachedPassword;
|
return this._state.cachedPassword;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue