@equinor/fusion-framework-react-app 6.2.2 → 6.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { type BookmarkData, type BookmarkPayloadGenerator, useCurrentBookmark as _useCurrentBookmark } from '@equinor/fusion-framework-react-module-bookmark';
1
+ import { type BookmarkData, type BookmarkPayloadGenerator, type useCurrentBookmarkReturn } from '@equinor/fusion-framework-react-module-bookmark';
2
2
  /**
3
3
  * By providing a CreateBookMarkFn bookmarks is enabled for the current application.
4
4
  *
@@ -11,5 +11,5 @@ import { type BookmarkData, type BookmarkPayloadGenerator, useCurrentBookmark as
11
11
  * ```
12
12
  * @return {*} {CurrentBookmark<TData>}
13
13
  */
14
- export declare const useCurrentBookmark: <TData extends BookmarkData>(payloadGenerator?: BookmarkPayloadGenerator<TData>) => ReturnType<typeof _useCurrentBookmark<TData>>;
14
+ export declare const useCurrentBookmark: <TData extends BookmarkData>(payloadGenerator?: BookmarkPayloadGenerator<TData>) => useCurrentBookmarkReturn<TData>;
15
15
  export default useCurrentBookmark;
@@ -1 +1 @@
1
- export declare const version = "6.2.2";
1
+ export declare const version = "6.2.4";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-react-app",
3
- "version": "6.2.2",
3
+ "version": "6.2.4",
4
4
  "description": "",
5
5
  "main": "./dist/esm/index.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -106,12 +106,12 @@
106
106
  "directory": "packages/react"
107
107
  },
108
108
  "dependencies": {
109
- "@equinor/fusion-framework-app": "^9.3.18",
109
+ "@equinor/fusion-framework-app": "^9.3.20",
110
110
  "@equinor/fusion-framework-module": "^4.4.2",
111
111
  "@equinor/fusion-framework-module-app": "^6.1.16",
112
112
  "@equinor/fusion-framework-module-navigation": "^5.0.3",
113
- "@equinor/fusion-framework-react": "^7.4.15",
114
113
  "@equinor/fusion-framework-react-module": "^3.1.12",
114
+ "@equinor/fusion-framework-react": "^7.4.15",
115
115
  "@equinor/fusion-framework-react-module-http": "^9.0.3"
116
116
  },
117
117
  "devDependencies": {
@@ -124,8 +124,8 @@
124
124
  "@equinor/fusion-framework-module-ag-grid": "^34.0.2",
125
125
  "@equinor/fusion-framework-module-event": "^4.3.6",
126
126
  "@equinor/fusion-framework-module-feature-flag": "^1.1.21",
127
- "@equinor/fusion-framework-react-module-bookmark": "^4.0.8",
128
127
  "@equinor/fusion-framework-module-msal": "^4.0.7",
128
+ "@equinor/fusion-framework-react-module-bookmark": "^4.0.11",
129
129
  "@equinor/fusion-framework-react-module-context": "^6.2.31",
130
130
  "@equinor/fusion-observable": "^8.5.1"
131
131
  },
@@ -1,11 +1,15 @@
1
1
  import {
2
2
  type BookmarkData,
3
3
  type BookmarkPayloadGenerator,
4
+ type useCurrentBookmarkReturn,
4
5
  useCurrentBookmark as _useCurrentBookmark,
6
+ type BookmarkModule,
7
+ bookmarkWithDataSchema,
5
8
  } from '@equinor/fusion-framework-react-module-bookmark';
6
- import type { BookmarkModule } from '../../../../modules/bookmark/src';
9
+
7
10
  import { useFrameworkModule } from '@equinor/fusion-framework-react';
8
11
  import useAppModules from '../useAppModules';
12
+ import { useCurrentApp } from '@equinor/fusion-framework-react/app';
9
13
 
10
14
  /**
11
15
  * By providing a CreateBookMarkFn bookmarks is enabled for the current application.
@@ -21,7 +25,8 @@ import useAppModules from '../useAppModules';
21
25
  */
22
26
  export const useCurrentBookmark = <TData extends BookmarkData>(
23
27
  payloadGenerator?: BookmarkPayloadGenerator<TData>,
24
- ): ReturnType<typeof _useCurrentBookmark<TData>> => {
28
+ ): useCurrentBookmarkReturn<TData> => {
29
+ const { currentApp } = useCurrentApp();
25
30
  const appBookmarkProvider = useAppModules<[BookmarkModule]>().bookmark;
26
31
  const frameworkBookmarkProvider = useFrameworkModule<BookmarkModule>('bookmark');
27
32
  if (!appBookmarkProvider) {
@@ -30,10 +35,19 @@ export const useCurrentBookmark = <TData extends BookmarkData>(
30
35
  'application has not enabled bookmarks, this will not work in the future',
31
36
  );
32
37
  }
33
- return _useCurrentBookmark<TData>({
38
+ const { currentBookmark, setCurrentBookmark } = _useCurrentBookmark<TData>({
34
39
  provider: appBookmarkProvider ?? frameworkBookmarkProvider,
35
40
  payloadGenerator,
36
41
  });
42
+
43
+ const currentBookmarkAppKey = bookmarkWithDataSchema().safeParse(currentBookmark).success
44
+ ? bookmarkWithDataSchema().parse(currentBookmark).appKey
45
+ : null;
46
+
47
+ return {
48
+ currentBookmark: currentBookmarkAppKey === currentApp?.appKey ? currentBookmark : null,
49
+ setCurrentBookmark,
50
+ };
37
51
  };
38
52
 
39
53
  export default useCurrentBookmark;
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '6.2.2';
2
+ export const version = '6.2.4';