@asgardeo/react 0.22.1 → 0.22.3

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.
@@ -94,6 +94,10 @@ export type AsgardeoContextProps = {
94
94
  * Flag indicating whether the SDK is working in the background.
95
95
  */
96
96
  isLoading: boolean;
97
+ /**
98
+ * Flag indicating whether flow metadata is currently being fetched.
99
+ */
100
+ isMetaLoading: boolean;
97
101
  /**
98
102
  * Flag indicating whether the user is signed in or not.
99
103
  */
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ var AsgardeoContext = createContext({
37
37
  instanceId: 0,
38
38
  isInitialized: false,
39
39
  isLoading: true,
40
+ isMetaLoading: false,
40
41
  isSignedIn: false,
41
42
  meta: null,
42
43
  organization: null,
@@ -1154,8 +1155,10 @@ var useAsgardeo = () => {
1154
1155
  const flowMetaContext = useContext(FlowMetaContext_default);
1155
1156
  const i18nContext = useContext(I18nContext_default);
1156
1157
  const meta = flowMetaContext?.meta ?? null;
1158
+ const isMetaLoading = flowMetaContext?.isLoading ?? false;
1157
1159
  return {
1158
1160
  ...context,
1161
+ isMetaLoading,
1159
1162
  meta,
1160
1163
  resolveFlowTemplateLiterals: (text) => resolveFlowTemplateLiterals(text, {
1161
1164
  meta,
@@ -1187,13 +1190,17 @@ var FlowMetaProvider = ({
1187
1190
  const { baseUrl, applicationId, platform } = useAsgardeo_default();
1188
1191
  const i18nContext = useI18n_default();
1189
1192
  const [meta, setMeta] = useState3(null);
1190
- const [isLoading, setIsLoading] = useState3(false);
1193
+ const [isLoading, setIsLoading] = useState3(true);
1191
1194
  const [error, setError] = useState3(null);
1192
1195
  const [pendingLanguage, setPendingLanguage] = useState3(null);
1193
- const hasFetchedRef = useRef(false);
1196
+ const lastFetchedRef = useRef(null);
1194
1197
  const fetchFlowMeta = useCallback3(async () => {
1195
1198
  if (!enabled || platform !== Platform2.AsgardeoV2) {
1196
1199
  setMeta(null);
1200
+ setIsLoading(false);
1201
+ return;
1202
+ }
1203
+ if (!applicationId) {
1197
1204
  return;
1198
1205
  }
1199
1206
  setIsLoading(true);
@@ -1249,11 +1256,10 @@ var FlowMetaProvider = ({
1249
1256
  }
1250
1257
  }, [pendingLanguage, i18nContext?.setLanguage]);
1251
1258
  useEffect2(() => {
1252
- if (!hasFetchedRef.current) {
1253
- hasFetchedRef.current = true;
1254
- fetchFlowMeta();
1259
+ if (lastFetchedRef.current === fetchFlowMeta) {
1255
1260
  return;
1256
1261
  }
1262
+ lastFetchedRef.current = fetchFlowMeta;
1257
1263
  fetchFlowMeta();
1258
1264
  }, [fetchFlowMeta]);
1259
1265
  useEffect2(() => {