This commit is contained in:
Manav Rathi
2024-11-06 18:30:56 +05:30
parent 53d01b2aa4
commit 748605ff00
2 changed files with 38 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import DownloadManager from "@/new/photos/services/download";
import { logoutML, terminateMLWorker } from "@/new/photos/services/ml";
import { logoutSearch } from "@/new/photos/services/search";
import { logoutSettings } from "@/new/photos/services/settings";
import { logoutUserDetails } from "@/new/photos/services/user";
import exportService from "./export";
/**
@@ -43,6 +44,12 @@ export const photosLogout = async () => {
ignoreError("settings", e);
}
try {
logoutUserDetails();
} catch (e) {
ignoreError("userDetails", e);
}
try {
resetUploadState();
} catch (e) {

View File

@@ -59,3 +59,34 @@ export const accountLogout = async () => {
ignoreError("KV DB", e);
}
};
/**
* This is a subset of the cleanup of local persistence that has already
* happened during {@link accountLogout}. However, once the logout sequence is
* complete, we do these specific steps again to clear any state that might've
* been persisted meanwhile because of in-flight requests getting completed.
*
* Post this, we'll reload the page so that in-flight requests are discarded.
*/
export const logoutClearStateAgain = async () => {
const ignoreError = (label: string, e: unknown) =>
log.error(`Ignoring error during logout (${label})`, e);
log.info("logout (sweep)");
try {
clearLocalStorage();
} catch (e) {
ignoreError("Local storage", e);
}
try {
await localForage.clear();
} catch (e) {
ignoreError("Local forage", e);
}
try {
await clearKVDB();
} catch (e) {
ignoreError("KV DB", e);
}
};