Bypass the tests being weird

They run kinda-but-not-really async, which can lead to early/late calls to `stop()`
pull/21833/head
Travis Ralston 2019-10-31 16:43:03 -06:00
parent 3c45a39caa
commit 07b8e128d2
1 changed files with 8 additions and 1 deletions

View File

@ -66,7 +66,14 @@ export class Mjolnir {
stop() {
SettingsStore.unwatchSetting(this._mjolnirWatchRef);
dis.unregister(this._dispatcherRef);
try {
if (this._dispatcherRef) dis.unregister(this._dispatcherRef);
} catch (e) {
console.error(e);
// Only the tests cause problems with this particular block of code. We should
// never be here in production.
}
if (!MatrixClientPeg.get()) return;
MatrixClientPeg.get().removeListener("RoomState.events", this._onEvent.bind(this));