@trackunit/react-core-contexts 1.7.0 → 1.8.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.
package/index.cjs.js CHANGED
@@ -96,7 +96,9 @@ const createApolloClient = ({ graphqlPublicUrl, graphqlInternalUrl, graphqlRepor
96
96
  },
97
97
  });
98
98
  const invalidToken = graphQLErrors.some(x => {
99
- return (x.extensions?.code === "UNAUTHENTICATED" ||
99
+ return (
100
+ // saw it not unnecessary
101
+ x.extensions?.code === "UNAUTHENTICATED" ||
100
102
  x.message.includes("Invalid token specified") ||
101
103
  x.message.includes("Access denied! You need to be authorized to perform this action!"));
102
104
  });
@@ -213,10 +215,11 @@ const useApolloClient = () => {
213
215
  errorHandler,
214
216
  });
215
217
  });
216
- react.useEffect(() => {
218
+ react.useMemo(() => {
217
219
  if (client.getToken() !== currentToken) {
218
220
  client.setToken(currentToken);
219
221
  }
222
+ return currentToken;
220
223
  }, [client, currentToken]);
221
224
  return client;
222
225
  };
package/index.esm.js CHANGED
@@ -7,7 +7,7 @@ import { getMainDefinition, Observable } from '@apollo/client/utilities';
7
7
  import { useEnvironment, useToken, useErrorHandler, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, EnvironmentContextProvider, ErrorHandlingContextProvider, FilterBarProvider, ModalDialogContextProvider, NavigationContextProvider, OemBrandingContextProvider, TimeRangeProvider, ToastProvider, TokenProvider, CurrentUserProvider, CurrentUserPreferenceProvider, UserSubscriptionProvider, WidgetConfigProvider } from '@trackunit/react-core-hooks';
8
8
  import { print } from 'graphql';
9
9
  import { createClient } from 'graphql-sse';
10
- import { useState, useEffect, useMemo, Suspense } from 'react';
10
+ import { useState, useMemo, useEffect, Suspense } from 'react';
11
11
  import '@js-temporal/polyfill';
12
12
  import { registerTranslations, initializeTranslationsForApp } from '@trackunit/i18n-library-translation';
13
13
  import { Spinner } from '@trackunit/react-components';
@@ -94,7 +94,9 @@ const createApolloClient = ({ graphqlPublicUrl, graphqlInternalUrl, graphqlRepor
94
94
  },
95
95
  });
96
96
  const invalidToken = graphQLErrors.some(x => {
97
- return (x.extensions?.code === "UNAUTHENTICATED" ||
97
+ return (
98
+ // saw it not unnecessary
99
+ x.extensions?.code === "UNAUTHENTICATED" ||
98
100
  x.message.includes("Invalid token specified") ||
99
101
  x.message.includes("Access denied! You need to be authorized to perform this action!"));
100
102
  });
@@ -211,10 +213,11 @@ const useApolloClient = () => {
211
213
  errorHandler,
212
214
  });
213
215
  });
214
- useEffect(() => {
216
+ useMemo(() => {
215
217
  if (client.getToken() !== currentToken) {
216
218
  client.setToken(currentToken);
217
219
  }
220
+ return currentToken;
218
221
  }, [client, currentToken]);
219
222
  return client;
220
223
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts",
3
- "version": "1.7.0",
3
+ "version": "1.8.4",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -11,15 +11,15 @@
11
11
  "react": "19.0.0",
12
12
  "@js-temporal/polyfill": "^0.4.4",
13
13
  "jest-fetch-mock": "^3.0.3",
14
- "@trackunit/iris-app-api": "1.6.0",
15
- "@trackunit/react-core-contexts-api": "1.7.0",
16
- "@trackunit/react-core-hooks": "1.6.0",
17
- "@trackunit/i18n-library-translation": "1.6.0",
18
- "@trackunit/react-components": "1.7.0",
19
- "@trackunit/iris-app-runtime-core": "1.7.0",
14
+ "@trackunit/iris-app-api": "1.6.4",
15
+ "@trackunit/react-core-contexts-api": "1.7.4",
16
+ "@trackunit/react-core-hooks": "1.6.4",
17
+ "@trackunit/i18n-library-translation": "1.6.4",
18
+ "@trackunit/react-components": "1.7.5",
19
+ "@trackunit/iris-app-runtime-core": "1.7.4",
20
20
  "graphql": "^16.10.0",
21
21
  "graphql-sse": "^2.5.4",
22
- "@trackunit/react-test-setup": "1.3.0"
22
+ "@trackunit/react-test-setup": "1.3.4"
23
23
  },
24
24
  "module": "./index.esm.js",
25
25
  "main": "./index.cjs.js",