@djangocfg/api 2.1.548 → 2.1.550
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/dist/auth.cjs +9 -4
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.mjs +9 -4
- package/dist/auth.mjs.map +1 -1
- package/package.json +2 -2
- package/src/auth/context/AccountsContext.tsx +17 -4
package/dist/auth.mjs
CHANGED
|
@@ -4540,6 +4540,7 @@ function AccountsProvider({ children }) {
|
|
|
4540
4540
|
const [profileError, setProfileError] = useState10(null);
|
|
4541
4541
|
const profileRef = useRef5(profile);
|
|
4542
4542
|
const isLoadingRef = useRef5(false);
|
|
4543
|
+
const fetchSeqRef = useRef5(0);
|
|
4543
4544
|
useEffect5(() => {
|
|
4544
4545
|
profileRef.current = profile;
|
|
4545
4546
|
}, [profile]);
|
|
@@ -4558,10 +4559,11 @@ function AccountsProvider({ children }) {
|
|
|
4558
4559
|
authLogger.debug(`No API origin configured, skipping profile fetch (caller: ${callerId})`);
|
|
4559
4560
|
return void 0;
|
|
4560
4561
|
}
|
|
4561
|
-
if (isLoadingRef.current) {
|
|
4562
|
+
if (isLoadingRef.current && !force) {
|
|
4562
4563
|
authLogger.debug(`Profile loading in progress, skipping (caller: ${callerId})`);
|
|
4563
4564
|
return profileRef.current;
|
|
4564
4565
|
}
|
|
4566
|
+
const seq = ++fetchSeqRef.current;
|
|
4565
4567
|
setIsLoadingProfile(true);
|
|
4566
4568
|
isLoadingRef.current = true;
|
|
4567
4569
|
setProfileError(null);
|
|
@@ -4569,17 +4571,20 @@ function AccountsProvider({ children }) {
|
|
|
4569
4571
|
authLogger.debug(`Fetching profile from API (caller: ${callerId}, force: ${force})`);
|
|
4570
4572
|
const res = await CfgAccountsProfile.cfgAccountsProfileRetrieve({ throwOnError: true });
|
|
4571
4573
|
const result = res.data;
|
|
4574
|
+
if (seq !== fetchSeqRef.current) return result;
|
|
4572
4575
|
setProfile(result);
|
|
4573
4576
|
profileRef.current = result;
|
|
4574
4577
|
setCachedProfile(result);
|
|
4575
4578
|
return result;
|
|
4576
4579
|
} catch (error) {
|
|
4577
4580
|
const err = error instanceof Error ? error : new Error("Failed to fetch profile");
|
|
4578
|
-
setProfileError(err);
|
|
4581
|
+
if (seq === fetchSeqRef.current) setProfileError(err);
|
|
4579
4582
|
throw err;
|
|
4580
4583
|
} finally {
|
|
4581
|
-
|
|
4582
|
-
|
|
4584
|
+
if (seq === fetchSeqRef.current) {
|
|
4585
|
+
setIsLoadingProfile(false);
|
|
4586
|
+
isLoadingRef.current = false;
|
|
4587
|
+
}
|
|
4583
4588
|
}
|
|
4584
4589
|
}, []);
|
|
4585
4590
|
const updateProfile = useCallback10(async (data) => {
|