Provide control at init time for web plugins

The control interface is required for adding handlers for message types
a plugin defines, but the plugins were loaded before the Control
instance was created. This meant there was no sensible way for web
plugins to register handlers for their own message types.

Move the creating of the Control instance to before plugins are loaded
and set this.control for web plugins before init is called.
This commit is contained in:
Hornwitser committed 2023-11-28 15:35:40 +01:00
1 parent 70d2b319b3
commit 8c724e3bc5
4 files changed
+17 -16

No files matched your search

+3 -5
View File
@@ -52,6 +52,9 @@ export class Control extends lib.Link {
/** Roles of the account this control link is connected as. */
accountRoles: lib.AccountRole[] | null = null;
/** Plugins loaded in the web interface */
public plugins = new Map<string, BaseWebPlugin>();
/** Updates not handled by the subscription service */
accountUpdateHandlers: accountHandler[] = [];
logHandlers: Map<lib.LogFilter, logHandler[]> = new Map();
@@ -85,14 +88,9 @@ export class Control extends lib.Link {
constructor(
connector: ControlConnector,
public plugins: Map<string, BaseWebPlugin>,
) {
super(connector);
for (let plugin of plugins.values()) {
plugin.control = this;
}
this.connector.on("connect", data => {
this.accountName = data.account.name;
this.accountRoles = data.account.roles;