Add some null checks

This commit is contained in:
David Baker 2017-12-05 11:14:55 +00:00
parent 4f58b92a14
commit c23a3fd7fe
2 changed files with 5 additions and 3 deletions

View file

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

View file

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