@trackunit/react-core-contexts 0.4.163 → 0.4.165

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 +7 -3
  2. package/index.js +7 -3
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -167,14 +167,18 @@ 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
+ const { isAssuming } = reactCoreHooks.useCurrentUser();
171
171
  const { token } = reactCoreHooks.useToken();
172
- const tasUserIdRef = React__namespace.useRef(tasUserId);
172
+ const isAssumingRef = React__namespace.useRef();
173
173
  const clientRef = React__namespace.useRef(null);
174
+ if (isAssumingRef.current === null) {
175
+ isAssumingRef.current = isAssuming;
176
+ }
174
177
  /* DONT CHANGE THIS ! its there to ensure we dont recreate apollo client just because the token changes,
175
178
  the token will then be set on the instance without react reporting a new client
176
179
  and recreating if token change from null to something*/
177
- if (!clientRef.current || !clientRef.current.getToken() || tasUserIdRef.current !== tasUserId) {
180
+ if (!clientRef.current || !clientRef.current.getToken() || isAssumingRef.current !== isAssuming) {
181
+ isAssumingRef.current = !isAssumingRef.current;
178
182
  clientRef.current = createApolloClient({
179
183
  graphqlManagerUrl,
180
184
  graphqlPublicUrl,
package/index.js CHANGED
@@ -143,14 +143,18 @@ 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
+ const { isAssuming } = useCurrentUser();
147
147
  const { token } = useToken();
148
- const tasUserIdRef = React.useRef(tasUserId);
148
+ const isAssumingRef = React.useRef();
149
149
  const clientRef = React.useRef(null);
150
+ if (isAssumingRef.current === null) {
151
+ isAssumingRef.current = isAssuming;
152
+ }
150
153
  /* DONT CHANGE THIS ! its there to ensure we dont recreate apollo client just because the token changes,
151
154
  the token will then be set on the instance without react reporting a new client
152
155
  and recreating if token change from null to something*/
153
- if (!clientRef.current || !clientRef.current.getToken() || tasUserIdRef.current !== tasUserId) {
156
+ if (!clientRef.current || !clientRef.current.getToken() || isAssumingRef.current !== isAssuming) {
157
+ isAssumingRef.current = !isAssumingRef.current;
154
158
  clientRef.current = createApolloClient({
155
159
  graphqlManagerUrl,
156
160
  graphqlPublicUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts",
3
- "version": "0.4.163",
3
+ "version": "0.4.165",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {