Skip to content

Build your personal knowledge base with Trilium Notes

fix(share): load the app context before a hosted view's module

Elian Doran93dae9083326
diff --git a/packages/share-theme/src/content/app_view.ts b/packages/share-theme/src/content/app_view.ts
index ebe8bc73ba..5b68cd69d5 100644
--- a/packages/share-theme/src/content/app_view.ts
+++ b/packages/share-theme/src/content/app_view.ts
@@ -8,7 +8,9 @@ export interface AppViewModule {
/**
* Mounts an app view on the page, if `#content` has its `container`, from the payload core embeds
* beside it. The view brings the app's context along, which expects jQuery as a global, so
- * `app_globals.ts` loads before the view's module.
+ * `app_globals.ts` loads first. `app_context.ts` then loads before the view's module, as in the
+ * app's entry: the modules it reaches depend on that order, such as `tree.ts`, which uses `ws.ts`
+ * as it loads.
*/
export default async function setupAppView(container: string, load: () => Promise<AppViewModule>) {
const element = document.querySelector<HTMLElement>(`#content ${container}`);
@@ -18,6 +20,7 @@ export default async function setupAppView(container: string, load: () => Promis
}
await import("./app_globals.js");
+ await import("@triliumnext/client/src/components/app_context.js");
const { default: mount } = await load();
mount(element, JSON.parse(data.textContent));
}