Compare commits
2 commits
010aa2c2fc
...
6a773367d4
Author | SHA1 | Date | |
---|---|---|---|
6a773367d4 | |||
70cca596e4 |
2 changed files with 9 additions and 2 deletions
|
@ -204,10 +204,10 @@ export default async function trackLocation() {
|
||||||
// Create throttled version of auth reload with lodash
|
// Create throttled version of auth reload with lodash
|
||||||
const reloadAuth = throttle(_reloadAuth, AUTH_RELOAD_THROTTLE, {
|
const reloadAuth = throttle(_reloadAuth, AUTH_RELOAD_THROTTLE, {
|
||||||
leading: true,
|
leading: true,
|
||||||
trailing: true,
|
trailing: false, // Prevent trailing calls to avoid duplicate refreshes
|
||||||
});
|
});
|
||||||
|
|
||||||
BackgroundGeolocation.onHttp((response) => {
|
BackgroundGeolocation.onHttp(async (response) => {
|
||||||
// Log the full response including headers if available
|
// Log the full response including headers if available
|
||||||
locationLogger.debug("HTTP response received", {
|
locationLogger.debug("HTTP response received", {
|
||||||
status: response?.status,
|
status: response?.status,
|
||||||
|
|
|
@ -153,6 +153,7 @@ export default createAtom(({ get, merge, getActions }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLoading()) {
|
if (isLoading()) {
|
||||||
|
authLogger.info("Auth is already loading, waiting for completion");
|
||||||
await loadingPromise;
|
await loadingPromise;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -162,9 +163,15 @@ export default createAtom(({ get, merge, getActions }) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
startLoading();
|
startLoading();
|
||||||
|
|
||||||
|
authLogger.debug("Deleting userToken for refresh");
|
||||||
await secureStore.deleteItemAsync("userToken");
|
await secureStore.deleteItemAsync("userToken");
|
||||||
|
|
||||||
await init();
|
await init();
|
||||||
return true;
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
authLogger.error("Auth reload failed", { error: error.message });
|
||||||
|
throw error;
|
||||||
} finally {
|
} finally {
|
||||||
// Clear reloading state even if there was an error
|
// Clear reloading state even if there was an error
|
||||||
merge({ isReloading: false });
|
merge({ isReloading: false });
|
||||||
|
|
Loading…
Add table
Reference in a new issue