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(); }, []); };