@trackunit/react-core-contexts 0.4.162 → 0.4.163

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.
Files changed (3) hide show
  1. package/index.cjs +3 -1
  2. package/index.js +4 -2
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -167,12 +167,14 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
167
167
  const useApolloClient = (isIrisApp) => {
168
168
  var _a;
169
169
  const { graphqlManagerUrl, graphqlPublicUrl, graphqlManagerImageUploadUrl, graphqlReportUrl, isDev, tracingHeaders } = reactCoreHooks.useEnvironment();
170
+ const { tasUserId } = reactCoreHooks.useCurrentUser();
170
171
  const { token } = reactCoreHooks.useToken();
172
+ const tasUserIdRef = React__namespace.useRef(tasUserId);
171
173
  const clientRef = React__namespace.useRef(null);
172
174
  /* DONT CHANGE THIS ! its there to ensure we dont recreate apollo client just because the token changes,
173
175
  the token will then be set on the instance without react reporting a new client
174
176
  and recreating if token change from null to something*/
175
- if (!clientRef.current || !clientRef.current.getToken()) {
177
+ if (!clientRef.current || !clientRef.current.getToken() || tasUserIdRef.current !== tasUserId) {
176
178
  clientRef.current = createApolloClient({
177
179
  graphqlManagerUrl,
178
180
  graphqlPublicUrl,
package/index.js CHANGED
@@ -3,7 +3,7 @@ import { ApolloProvider, ApolloClient, InMemoryCache, from, split } from '@apoll
3
3
  import { setContext } from '@apollo/client/link/context';
4
4
  import { onError } from '@apollo/client/link/error';
5
5
  import * as Sentry from '@sentry/browser';
6
- import { useEnvironment, useToken, ToastProvider, AnalyticsContextProvider, AssetSortingProvider, EnvironmentContextProvider, GlobalSelectionProvider, OemBrandingContextProvider as OemBrandingContextProvider$1, TokenProvider, CurrentUserProvider, UserSubscriptionProvider as UserSubscriptionProvider$1, useURLSynchronization } from '@trackunit/react-core-hooks';
6
+ import { useEnvironment, useCurrentUser, useToken, ToastProvider, AnalyticsContextProvider, AssetSortingProvider, EnvironmentContextProvider, GlobalSelectionProvider, OemBrandingContextProvider as OemBrandingContextProvider$1, TokenProvider, CurrentUserProvider, UserSubscriptionProvider as UserSubscriptionProvider$1, useURLSynchronization } from '@trackunit/react-core-hooks';
7
7
  import { createUploadLink } from 'apollo-upload-client';
8
8
  import * as React from 'react';
9
9
  import { useMemo, useEffect, useState } from 'react';
@@ -143,12 +143,14 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
143
143
  const useApolloClient = (isIrisApp) => {
144
144
  var _a;
145
145
  const { graphqlManagerUrl, graphqlPublicUrl, graphqlManagerImageUploadUrl, graphqlReportUrl, isDev, tracingHeaders } = useEnvironment();
146
+ const { tasUserId } = useCurrentUser();
146
147
  const { token } = useToken();
148
+ const tasUserIdRef = React.useRef(tasUserId);
147
149
  const clientRef = React.useRef(null);
148
150
  /* DONT CHANGE THIS ! its there to ensure we dont recreate apollo client just because the token changes,
149
151
  the token will then be set on the instance without react reporting a new client
150
152
  and recreating if token change from null to something*/
151
- if (!clientRef.current || !clientRef.current.getToken()) {
153
+ if (!clientRef.current || !clientRef.current.getToken() || tasUserIdRef.current !== tasUserId) {
152
154
  clientRef.current = createApolloClient({
153
155
  graphqlManagerUrl,
154
156
  graphqlPublicUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts",
3
- "version": "0.4.162",
3
+ "version": "0.4.163",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {