From 707fd6062446d86bcbf2ed7b8452e3e8996d8c95 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 23 Mar 2017 10:38:00 +0000 Subject: [PATCH] Prevent crash on login of no guest session The bound functions are only set when the Notifier is started, so if stop() was called without start() having been called, the listener function would be null which would throw an exception. --- src/Notifier.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Notifier.js b/src/Notifier.js index 67642e734a9..7fc7d3e338f 100644 --- a/src/Notifier.js +++ b/src/Notifier.js @@ -1,5 +1,6 @@ /* Copyright 2015, 2016 OpenMarket Ltd +Copyright 2017 Vector Creations Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,8 +15,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -'use strict'; - var MatrixClientPeg = require("./MatrixClientPeg"); var PlatformPeg = require("./PlatformPeg"); var TextForEvent = require('./TextForEvent'); @@ -103,7 +102,7 @@ var Notifier = { }, stop: function() { - if (MatrixClientPeg.get()) { + if (MatrixClientPeg.get() && this.boundOnRoomTimeline) { MatrixClientPeg.get().removeListener('Room.timeline', this.boundOnRoomTimeline); MatrixClientPeg.get().removeListener("Room.receipt", this.boundOnRoomReceipt); MatrixClientPeg.get().removeListener('sync', this.boundOnSyncStateChange);