mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
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:
1 parent
70d2b319b3
commit
8c724e3bc5
4 files changed
+17
-16
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user