@trackunit/react-core-contexts 0.4.164 → 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.
- package/index.cjs +6 -5
- package/index.js +6 -5
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -167,17 +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 {
|
|
170
|
+
const { isAssuming } = reactCoreHooks.useCurrentUser();
|
|
171
171
|
const { token } = reactCoreHooks.useToken();
|
|
172
|
-
const
|
|
172
|
+
const isAssumingRef = React__namespace.useRef();
|
|
173
173
|
const clientRef = React__namespace.useRef(null);
|
|
174
|
-
if (
|
|
175
|
-
|
|
174
|
+
if (isAssumingRef.current === null) {
|
|
175
|
+
isAssumingRef.current = isAssuming;
|
|
176
176
|
}
|
|
177
177
|
/* DONT CHANGE THIS ! its there to ensure we dont recreate apollo client just because the token changes,
|
|
178
178
|
the token will then be set on the instance without react reporting a new client
|
|
179
179
|
and recreating if token change from null to something*/
|
|
180
|
-
if (!clientRef.current || !clientRef.current.getToken() ||
|
|
180
|
+
if (!clientRef.current || !clientRef.current.getToken() || isAssumingRef.current !== isAssuming) {
|
|
181
|
+
isAssumingRef.current = !isAssumingRef.current;
|
|
181
182
|
clientRef.current = createApolloClient({
|
|
182
183
|
graphqlManagerUrl,
|
|
183
184
|
graphqlPublicUrl,
|
package/index.js
CHANGED
|
@@ -143,17 +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 {
|
|
146
|
+
const { isAssuming } = useCurrentUser();
|
|
147
147
|
const { token } = useToken();
|
|
148
|
-
const
|
|
148
|
+
const isAssumingRef = React.useRef();
|
|
149
149
|
const clientRef = React.useRef(null);
|
|
150
|
-
if (
|
|
151
|
-
|
|
150
|
+
if (isAssumingRef.current === null) {
|
|
151
|
+
isAssumingRef.current = isAssuming;
|
|
152
152
|
}
|
|
153
153
|
/* DONT CHANGE THIS ! its there to ensure we dont recreate apollo client just because the token changes,
|
|
154
154
|
the token will then be set on the instance without react reporting a new client
|
|
155
155
|
and recreating if token change from null to something*/
|
|
156
|
-
if (!clientRef.current || !clientRef.current.getToken() ||
|
|
156
|
+
if (!clientRef.current || !clientRef.current.getToken() || isAssumingRef.current !== isAssuming) {
|
|
157
|
+
isAssumingRef.current = !isAssumingRef.current;
|
|
157
158
|
clientRef.current = createApolloClient({
|
|
158
159
|
graphqlManagerUrl,
|
|
159
160
|
graphqlPublicUrl,
|