This commit is contained in:
Manav Rathi
2024-05-29 12:25:28 +05:30
parent 9c60fe6f3f
commit f0f3af96d1
2 changed files with 18 additions and 12 deletions

View File

@@ -14,18 +14,21 @@ import mlWorkManager from "./machineLearning/mlWorkManager";
* See: [Note: Do not throw during logout].
*/
export const photosLogout = async () => {
const ignoreError = (e: unknown, label: string) =>
log.error(`Ignoring error during logout (${label})`, e);
await accountLogout();
try {
await DownloadManager.logout();
} catch (e) {
log.error("Ignoring error during logout (download)", e);
ignoreError("download", e);
}
try {
await clipService.logout();
} catch (e) {
log.error("Ignoring error during logout (CLIP)", e);
ignoreError("CLIP", e);
}
const electron = globalThis.electron;
@@ -33,25 +36,25 @@ export const photosLogout = async () => {
try {
await mlWorkManager.logout();
} catch (e) {
log.error("Ignoring error during logout (ML)", e);
ignoreError("ML", e);
}
try {
await clearFaceData();
} catch (e) {
log.error("Ignoring error during logout (face)", e);
ignoreError("face", e);
}
try {
exportService.disableContinuousExport();
} catch (e) {
log.error("Ignoring error during logout (export)", e);
ignoreError("export", e);
}
try {
await electron?.logout();
} catch (e) {
log.error("Ignoring error during logout (electron)", e);
ignoreError("electron", e);
}
}
};

View File

@@ -17,34 +17,37 @@ import { logout as remoteLogout } from "../api/user";
* gets in an unexpected state.
*/
export const accountLogout = async () => {
const ignoreError = (e: unknown, label: string) =>
log.error(`Ignoring error during logout (${label})`, e);
try {
await remoteLogout();
} catch (e) {
log.error("Ignoring error during logout (remote)", e);
ignoreError("remote", e);
}
try {
InMemoryStore.clear();
} catch (e) {
log.error("Ignoring error during logout (in-memory store)", e);
ignoreError("in-memory store", e);
}
try {
clearKeys();
} catch (e) {
log.error("Ignoring error during logout (session store)", e);
ignoreError("session store", e);
}
try {
clearData();
} catch (e) {
log.error("Ignoring error during logout (local storage)", e);
ignoreError("local storage", e);
}
try {
await localForage.clear();
} catch (e) {
log.error("Ignoring error during logout (local forage)", e);
ignoreError("local forage", e);
}
try {
await clearBlobCaches();
} catch (e) {
log.error("Ignoring error during logout (cache)", e);
ignoreError("cache", e);
}
};