diff --git a/app/.server/classes/Plugins/index.ts b/app/.server/classes/Plugins/index.ts index 374bec8b..6307ee7f 100644 --- a/app/.server/classes/Plugins/index.ts +++ b/app/.server/classes/Plugins/index.ts @@ -82,8 +82,6 @@ export default class BasePlugin extends FSDataStore { this.active = data.active ?? true; this.default = data.default ?? false; storedServer = server; - - this.loadAspects(); } get server() { return storedServer; diff --git a/app/.server/classes/ServerDataModel.ts b/app/.server/classes/ServerDataModel.ts index 1dc65f59..14881c90 100644 --- a/app/.server/classes/ServerDataModel.ts +++ b/app/.server/classes/ServerDataModel.ts @@ -45,7 +45,9 @@ export class ServerDataModel extends FSDataStore { for await (const plugin of plugins) { const name = pluginRegex.exec(plugin)![1]; try { - this.plugins.push(new BasePlugin({ name }, this)); + const plugin = new BasePlugin({ name }, this); + await plugin.loadAspects(); + this.plugins.push(plugin); } catch (err) { console.error(`Error loading plugin ${name}:`, err); } diff --git a/app/.server/data/plugins/index.ts b/app/.server/data/plugins/index.ts index 65b769c0..e403d6bd 100644 --- a/app/.server/data/plugins/index.ts +++ b/app/.server/data/plugins/index.ts @@ -43,9 +43,10 @@ export const plugin = t.router({ }), create: t.procedure .input(z.object({ name: z.string() })) - .send(({ ctx, input }) => { + .send(async ({ ctx, input }) => { inputAuth(ctx); const plugin = new BasePlugin(input, ctx.server); + await plugin.loadAspects(); ctx.server.plugins.push(plugin); publish(plugin.id); return { pluginId: plugin.id };