Make Mjolnir stop more robust
Since Mjolnir is a shared instance, we need to be a bit more careful about clearing internal state than we do for components. This clears watcher and dispatcher refs in case `stop` is called multiple times (which can happen in prod as well as tests).
This commit is contained in:
parent
49fe1887df
commit
c425d7f02f
1 changed files with 7 additions and 7 deletions
|
@ -65,14 +65,14 @@ export class Mjolnir {
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
|
if (this._mjolnirWatchRef) {
|
||||||
SettingsStore.unwatchSetting(this._mjolnirWatchRef);
|
SettingsStore.unwatchSetting(this._mjolnirWatchRef);
|
||||||
|
this._mjolnirWatchRef = null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
if (this._dispatcherRef) {
|
||||||
if (this._dispatcherRef) dis.unregister(this._dispatcherRef);
|
dis.unregister(this._dispatcherRef);
|
||||||
} catch (e) {
|
this._dispatcherRef = null;
|
||||||
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;
|
||||||
|
|
Loading…
Reference in a new issue