dont load plugin resources at startup (delays important loads). load on demand if we open the apps screen.

This commit is contained in:
sawka 2023-11-08 00:12:41 -08:00
parent 86436d050e
commit 8daac68aad
3 changed files with 22 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import { boundMethod } from "autobind-decorator";
import cn from "classnames"; import cn from "classnames";
import dayjs from "dayjs"; import dayjs from "dayjs";
import type { RemoteType } from "../../types/types"; import type { RemoteType } from "../../types/types";
import { If, For } from "tsx-control-statements/components";
import { ReactComponent as LeftChevronIcon } from "../assets/icons/chevron_left.svg"; import { ReactComponent as LeftChevronIcon } from "../assets/icons/chevron_left.svg";
import { ReactComponent as HelpIcon } from "../assets/icons/help.svg"; import { ReactComponent as HelpIcon } from "../assets/icons/help.svg";
@ -235,11 +236,17 @@ class MainSideBar extends React.Component<{}, {}> {
<SettingsIcon className="icon" /> <SettingsIcon className="icon" />
Settings Settings
</div> </div>
<div className="item hoverEffect unselectable" onClick={() => openLink("https://docs.getprompt.dev")}> <div
className="item hoverEffect unselectable"
onClick={() => openLink("https://docs.getprompt.dev")}
>
<HelpIcon className="icon" /> <HelpIcon className="icon" />
Documentation Documentation
</div> </div>
<div className="item hoverEffect unselectable" onClick={() => openLink("https://discord.gg/XfvZ334gwU")}> <div
className="item hoverEffect unselectable"
onClick={() => openLink("https://discord.gg/XfvZ334gwU")}
>
<DiscordIcon className="icon discord" /> <DiscordIcon className="icon discord" />
Discord Discord
</div> </div>

View File

@ -2455,6 +2455,7 @@ class PluginsModel {
selectedPlugin: OV<RendererPluginType> = mobx.observable.box(null, { name: "selectedPlugin" }); selectedPlugin: OV<RendererPluginType> = mobx.observable.box(null, { name: "selectedPlugin" });
showPluginsView(): void { showPluginsView(): void {
PluginModel.loadAllPluginResources();
mobx.action(() => { mobx.action(() => {
this.reset(); this.reset();
GlobalModel.activeMainView.set("plugins"); GlobalModel.activeMainView.set("plugins");

View File

@ -82,6 +82,7 @@ const PluginConfigs: RendererPluginType[] = [
]; ];
class PluginModelClass { class PluginModelClass {
resourcesLoaded: boolean = false;
rendererPlugins: RendererPluginType[] = []; rendererPlugins: RendererPluginType[] = [];
constructor(pluginConfigs: RendererPluginType[]) { constructor(pluginConfigs: RendererPluginType[]) {
@ -97,11 +98,21 @@ class PluginModelClass {
throw new Error(sprintf("plugin with name %s already registered", plugin.name)); throw new Error(sprintf("plugin with name %s already registered", plugin.name));
} }
this.rendererPlugins.push(plugin); this.rendererPlugins.push(plugin);
this.loadPluginResources(plugin); // this.loadPluginResources(plugin);
return plugin; return plugin;
}); });
} }
loadAllPluginResources() {
if (this.resourcesLoaded) {
return;
}
this.resourcesLoaded = true;
for (let plugin of this.rendererPlugins) {
this.loadPluginResources(plugin);
}
}
// attach all screenshots. webpack doesnt allow dynamic paths, hence, we have to put static paths for each plugin // attach all screenshots. webpack doesnt allow dynamic paths, hence, we have to put static paths for each plugin
attachScreenshots(plugin) { attachScreenshots(plugin) {
let screenshotsContext; let screenshotsContext;