Skip to content

Commit

Permalink
Bypass the tests being weird
Browse files Browse the repository at this point in the history
They run kinda-but-not-really async, which can lead to early/late calls to `stop()`
  • Loading branch information
turt2live committed Oct 31, 2019
1 parent 3c45a39 commit 07b8e12
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/mjolnir/Mjolnir.js
Expand Up @@ -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));
Expand Down

0 comments on commit 07b8e12

Please sign in to comment.