Skip to content

Commit

Permalink
Load plugin CSS even if plugin takes too long
Browse files Browse the repository at this point in the history
  • Loading branch information
colin273 committed Jul 6, 2024
1 parent 3bbef14 commit 2381269
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/renderer/managers/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,21 @@ export async function start(id: string): Promise<void> {
);
plugin.exports = pluginExports;
await pluginExports.start?.();
if (plugin.hasCSS) {
if (styleElements.has(plugin.manifest.id)) {
// Remove old style element in case it wasn't removed properly
styleElements.get(plugin.manifest.id)?.remove();
}

const el = loadStyleSheet(
`replugged://plugin/${plugin.path}/${plugin.manifest.renderer?.replace(/\.js$/, ".css")}`,
);
styleElements.set(plugin.manifest.id, el);
}
})(),
]);
}

if (plugin.hasCSS) {
if (styleElements.has(plugin.manifest.id)) {
// Remove old style element in case it wasn't removed properly
styleElements.get(plugin.manifest.id)?.remove();
}

const el = loadStyleSheet(
`replugged://plugin/${plugin.path}/${plugin.manifest.renderer?.replace(/\.js$/, ".css")}`,
);
styleElements.set(plugin.manifest.id, el);
}

running.add(plugin.manifest.id);
logger.log(`Plugin started: ${plugin.manifest.name}`);
} catch (e: unknown) {
Expand Down

0 comments on commit 2381269

Please sign in to comment.