Remove boilerplate around dispatcher and settings watchers (#28338)

* Remove boilerplate around dispatcher and settings watchers

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2024-11-01 15:15:04 +00:00
committed by GitHub
parent b8fd98ab3c
commit 2d9982f9f0
36 changed files with 81 additions and 111 deletions
+7 -11
View File
@@ -22,12 +22,12 @@ import { Action } from "../dispatcher/actions";
// TODO: Move this and related files to the js-sdk or something once finalized.
export class Mjolnir {
private static instance: Mjolnir | null = null;
private static instance?: Mjolnir;
private _lists: BanList[] = []; // eslint-disable-line @typescript-eslint/naming-convention
private _roomIds: string[] = []; // eslint-disable-line @typescript-eslint/naming-convention
private mjolnirWatchRef: string | null = null;
private dispatcherRef: string | null = null;
private mjolnirWatchRef?: string;
private dispatcherRef?: string;
public get roomIds(): string[] {
return this._roomIds;
@@ -61,15 +61,11 @@ export class Mjolnir {
}
public stop(): void {
if (this.mjolnirWatchRef) {
SettingsStore.unwatchSetting(this.mjolnirWatchRef);
this.mjolnirWatchRef = null;
}
SettingsStore.unwatchSetting(this.mjolnirWatchRef);
this.mjolnirWatchRef = undefined;
if (this.dispatcherRef) {
dis.unregister(this.dispatcherRef);
this.dispatcherRef = null;
}
dis.unregister(this.dispatcherRef);
this.dispatcherRef = undefined;
MatrixClientPeg.get()?.removeListener(RoomStateEvent.Events, this.onEvent);
}