From 1074b8081615b1925424a51597bf7b4ab3a0da95 Mon Sep 17 00:00:00 2001 From: Christopher Berge Hove Date: Tue, 29 Oct 2024 15:31:34 +0100 Subject: [PATCH] chore: Update package.json and add new dependency Bump the version in package.json from 0.0.5 to 0.0.6. Also, add the new dependency "@equinor/fusion-framework-module-event" to the project. refactor: Update use-navigate-on-context-change.ts Refactor the use-navigate-on-context-change.ts file to use the updated modules from the fusion framework. Remove the unused imports and update the event listener to use the "onCurrentContextChanged" event. --- client/apps/project-portal-landingpage/package.json | 3 ++- .../src/hooks/use-navigate-on-context-change.ts | 12 +++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/client/apps/project-portal-landingpage/package.json b/client/apps/project-portal-landingpage/package.json index 31dcfd82..3b09ee3e 100644 --- a/client/apps/project-portal-landingpage/package.json +++ b/client/apps/project-portal-landingpage/package.json @@ -1,6 +1,6 @@ { "name": "project-portal-landingpage", - "version": "0.0.5", + "version": "0.0.6", "description": "", "private": true, "type": "module", @@ -24,6 +24,7 @@ "@equinor/eds-core-react": "^0.42.2", "@equinor/eds-tokens": "^0.9.2", "@equinor/fusion-framework-module-context": "^5.0.12", + "@equinor/fusion-framework-module-event": "^4.2.4", "@equinor/fusion-framework-module-feature-flag": "^1.1.9", "@equinor/fusion-framework-module-http": "^6.2.0", "@equinor/fusion-framework-react-app": "5.2.10", diff --git a/client/apps/project-portal-landingpage/src/hooks/use-navigate-on-context-change.ts b/client/apps/project-portal-landingpage/src/hooks/use-navigate-on-context-change.ts index a68200a9..4c5c1125 100644 --- a/client/apps/project-portal-landingpage/src/hooks/use-navigate-on-context-change.ts +++ b/client/apps/project-portal-landingpage/src/hooks/use-navigate-on-context-change.ts @@ -1,19 +1,17 @@ import { NavigationModule } from '@equinor/fusion-framework-module-navigation'; import { useFramework } from '@equinor/fusion-framework-react-app/framework'; -import { useContextProvider } from '@equinor/fusion-framework-react-app/context'; import { getContextPageURL } from './utils'; import { useEffect } from 'react'; -import { IContextProvider } from '@equinor/fusion-framework-module-context'; +import { EventModule } from '@equinor/fusion-framework-module-event'; export const useNavigateOnContextChange = () => { - const { modules } = useFramework<[NavigationModule]>(); - const provider: IContextProvider = useContextProvider(); + const { modules } = useFramework<[NavigationModule, EventModule]>(); + useEffect(() => { - const sub = provider.currentContext$.subscribe((context) => { - const url = new URL(getContextPageURL(context), location.origin); + return modules.event.addEventListener('onCurrentContextChanged', (event) => { + const url = new URL(getContextPageURL(event.detail.next), location.origin); modules.navigation.replace(url); }); - return () => sub.unsubscribe(); }, []); };