Merge pull request #1646 from matrix-org/dbkr/nullchecks4u

Add some null checks
This commit is contained in:
David Baker 2017-12-05 11:59:24 +00:00 committed by GitHub
commit 130c056ed9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -389,6 +389,8 @@ function _persistCredentialsToLocalStorage(credentials) {
* Logs the current session out and transitions to the logged-out state * Logs the current session out and transitions to the logged-out state
*/ */
export function logout() { export function logout() {
if (!MatrixClientPeg.get()) return;
if (MatrixClientPeg.get().isGuest()) { if (MatrixClientPeg.get().isGuest()) {
// logout doesn't work for guest sessions // logout doesn't work for guest sessions
// Also we sometimes want to re-log in a guest session // Also we sometimes want to re-log in a guest session

View file

@ -53,8 +53,10 @@ export default class UserProvider extends AutocompleteProvider {
} }
destroy() { destroy() {
MatrixClientPeg.get().removeListener("Room.timeline", this._onRoomTimelineBound); if (MatrixClientPeg.get()) {
MatrixClientPeg.get().removeListener("RoomState.members", this._onRoomStateMemberBound); MatrixClientPeg.get().removeListener("Room.timeline", this._onRoomTimelineBound);
MatrixClientPeg.get().removeListener("RoomState.members", this._onRoomStateMemberBound);
}
} }
_onRoomTimeline(ev, room, toStartOfTimeline, removed, data) { _onRoomTimeline(ev, room, toStartOfTimeline, removed, data) {