Bypass the tests being weird

They run kinda-but-not-really async, which can lead to early/late calls to `stop()`
This commit is contained in:
Travis Ralston 2019-10-31 16:43:03 -06:00
parent 3c45a39caa
commit 07b8e128d2

View file

@ -66,7 +66,14 @@ export class Mjolnir {
stop() { stop() {
SettingsStore.unwatchSetting(this._mjolnirWatchRef); 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; if (!MatrixClientPeg.get()) return;
MatrixClientPeg.get().removeListener("RoomState.events", this._onEvent.bind(this)); MatrixClientPeg.get().removeListener("RoomState.events", this._onEvent.bind(this));