From 0b787741d6487ccc1fa67c12da7f645848df260c Mon Sep 17 00:00:00 2001 From: Christopher Berge Hove Date: Tue, 22 Oct 2024 10:40:47 +0200 Subject: [PATCH 1/2] refactor: Improve loading logic in LegacyAppContainer, by loading app from new app api with proxy --- .../legacy-interopt/LegacyAppContainer.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/apps/legacyAppLoader/src/app-loader/legacy-interopt/LegacyAppContainer.ts b/client/apps/legacyAppLoader/src/app-loader/legacy-interopt/LegacyAppContainer.ts index 7560b229..26a07c64 100644 --- a/client/apps/legacyAppLoader/src/app-loader/legacy-interopt/LegacyAppContainer.ts +++ b/client/apps/legacyAppLoader/src/app-loader/legacy-interopt/LegacyAppContainer.ts @@ -228,13 +228,13 @@ export class LegacyAppContainer extends EventEmitter { * assume if the manifest missing AppComponent or render, that loading is required */ - if (!AppComponent && !render) { - await this.#loadScript(key); + const manifest = this.#manifests.value[appKey] as unknown as AppManifest; + + if (!AppComponent && !render && manifest.build) { + await this.#loadScript(manifest); } await new Promise((resolve) => window.requestAnimationFrame(resolve)); - const manifest = this.#manifests.value[appKey] as unknown as AppManifest; - const currentApp = appProvider.current; if (currentApp && currentApp.appKey === appKey) { @@ -285,8 +285,9 @@ export class LegacyAppContainer extends EventEmitter { return this.updateComplete; } - async #loadScript(appKey: string): Promise { + async #loadScript(manifest: AppManifest): Promise { return new Promise((resolve, reject) => { + const { appKey, build } = manifest; const script = document.createElement('script'); script.async = true; script.id = appKey; @@ -296,8 +297,7 @@ export class LegacyAppContainer extends EventEmitter { script.addEventListener('load', () => resolve()); script.addEventListener('abort', () => reject()); script.addEventListener('error', () => reject()); - // Todo: Fix uri to mach the new structure - script.src = `${window['clientBaseUri']}/api/bundles/${appKey}.js`; + script.src = `/apps-proxy/bundles/apps/${appKey}/${build?.version}/${build?.entryPoint}`; }); } @@ -305,7 +305,7 @@ export class LegacyAppContainer extends EventEmitter { console.log('Updating'); this.#updateTask = new Promise((resolve, reject) => { this.#updateTask.state = 'pending'; - this.#appModules.app.getAllAppManifests().subscribe({ + this.#appModules.app.getAppManifests({ filterByCurrentUser: true }).subscribe({ complete: () => { this.#updateTask.state = 'fulfilled'; this.#lastUpdated = Date.now(); From 4dcb9c7162f127c178207a56fa352748d57d494c Mon Sep 17 00:00:00 2001 From: Noggling Date: Tue, 22 Oct 2024 08:41:38 +0000 Subject: [PATCH 2/2] chore: create pr-828-2137854066.md --- .changeset/pr-828-2137854066.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pr-828-2137854066.md diff --git a/.changeset/pr-828-2137854066.md b/.changeset/pr-828-2137854066.md new file mode 100644 index 00000000..6b2fd75b --- /dev/null +++ b/.changeset/pr-828-2137854066.md @@ -0,0 +1,5 @@ + +--- +"fusion-project-portal": patch +--- +Improve loading logic in LegacyAppContainer, by loading app from new app api with proxy