@equinor/roma-framework 2.0.3 → 2.1.0

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.
@@ -11,6 +11,7 @@ export * from './lib/api/roma';
11
11
  export * from './lib/api/ms-graph';
12
12
  export * from './lib/app-provider';
13
13
  export * from './lib/query/persister';
14
+ export * from './lib/query/broadcast-channel';
14
15
  export * from './lib/hooks/use-get-api-roles';
15
16
  export * from './lib/hooks/use-has-api-role';
16
17
  export * from './lib/error-handlers/http-error-handler';
@@ -0,0 +1 @@
1
+ export declare const queryInvalidationChannel: BroadcastChannel;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/roma-framework",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "repository": "https://github.com/equinor/tops-roma",
5
5
  "types": "./index.d.ts",
6
6
  "private": false,
package/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export * from './lib/api/roma';
11
11
  export * from './lib/api/ms-graph';
12
12
  export * from './lib/app-provider';
13
13
  export * from './lib/query/persister';
14
+ export * from './lib/query/broadcast-channel';
14
15
  export * from './lib/hooks/use-get-api-roles';
15
16
  export * from './lib/hooks/use-has-api-role';
16
17
  export * from './lib/error-handlers/http-error-handler';
@@ -0,0 +1 @@
1
+ export declare const queryInvalidationChannel: BroadcastChannel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/roma-framework",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "repository": "https://github.com/equinor/tops-roma",
5
5
  "types": "./index.d.ts",
6
6
  "private": false,
@@ -5095,6 +5095,9 @@ function createIDBPersister(idbValidKey = "reactQuery") {
5095
5095
  }
5096
5096
  };
5097
5097
  }
5098
+ const queryInvalidationChannel = new BroadcastChannel(
5099
+ "query-invalidation"
5100
+ );
5098
5101
  function parseJwt(token) {
5099
5102
  const parts = token.split(".");
5100
5103
  if (parts.length !== 3) {
@@ -5340,6 +5343,18 @@ const useManageWatchList = (system) => {
5340
5343
  const queryClient = useQueryClient();
5341
5344
  const updateMutator = useUpdateByUserIdAndId();
5342
5345
  const createMutator = useCreateSettingByUserId();
5346
+ const mutateSuccess = async () => {
5347
+ const key = getGetSettingsByAppShortNameQueryKey("notifications");
5348
+ try {
5349
+ await queryClient.resetQueries({
5350
+ queryKey: key
5351
+ });
5352
+ } catch (message) {
5353
+ console.error(message);
5354
+ } finally {
5355
+ queryInvalidationChannel.postMessage({ key });
5356
+ }
5357
+ };
5343
5358
  const saveSetting = (setting2) => {
5344
5359
  if (!setting2.id) {
5345
5360
  createMutator.mutate(
@@ -5351,11 +5366,7 @@ const useManageWatchList = (system) => {
5351
5366
  }
5352
5367
  },
5353
5368
  {
5354
- onSuccess: () => {
5355
- return queryClient.resetQueries({
5356
- queryKey: getGetSettingsByAppShortNameQueryKey("notifications")
5357
- });
5358
- }
5369
+ onSuccess: mutateSuccess
5359
5370
  }
5360
5371
  );
5361
5372
  } else {
@@ -5366,11 +5377,7 @@ const useManageWatchList = (system) => {
5366
5377
  data: setting2
5367
5378
  },
5368
5379
  {
5369
- onSuccess: () => {
5370
- return queryClient.resetQueries({
5371
- queryKey: getGetSettingsByAppShortNameQueryKey("notifications")
5372
- });
5373
- }
5380
+ onSuccess: mutateSuccess
5374
5381
  }
5375
5382
  );
5376
5383
  }
@@ -5446,6 +5453,7 @@ export {
5446
5453
  handleError,
5447
5454
  makeComponent,
5448
5455
  parseJwt,
5456
+ queryInvalidationChannel,
5449
5457
  useAddRomaConfiguration,
5450
5458
  useAddRomaConfigurationHook,
5451
5459
  useAddRomaConfigurationMutationOptions,