logout 2
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user