diff --git a/apps/main/src/lib/cleaner.ts b/apps/main/src/lib/cleaner.ts index 18832311c..bd7d4883b 100644 --- a/apps/main/src/lib/cleaner.ts +++ b/apps/main/src/lib/cleaner.ts @@ -5,10 +5,9 @@ import { getMainWindow } from "~/window" import { t } from "./i18n" -export const clearAllData = async () => { +export const clearAllDataAndConfirm = async () => { const win = getMainWindow() if (!win) return - const ses = win.webContents.session // Dialog to confirm const result = await dialog.showMessageBox({ @@ -17,11 +16,19 @@ export const clearAllData = async () => { message: t("dialog.clearAllData"), buttons: [t("dialog.yes"), t("dialog.no")], }) - const caller = callWindowExpose(win) if (result.response === 1) { return } + return clearAllData() +} + +export const clearAllData = async () => { + const win = getMainWindow() + if (!win) return + const ses = win.webContents.session + const caller = callWindowExpose(win) + try { await ses.clearCache() diff --git a/apps/main/src/menu.ts b/apps/main/src/menu.ts index 5217438a1..e985df608 100644 --- a/apps/main/src/menu.ts +++ b/apps/main/src/menu.ts @@ -4,7 +4,7 @@ import type { BrowserWindow, MenuItem, MenuItemConstructorOptions } from "electr import { Menu } from "electron" import { isDev, isMacOS } from "./env" -import { clearAllData } from "./lib/cleaner" +import { clearAllDataAndConfirm } from "./lib/cleaner" import { t } from "./lib/i18n" import { revealLogFile } from "./logger" import { checkForUpdates, quitAndInstall } from "./updater" @@ -38,7 +38,7 @@ export const registerAppMenu = () => { { type: "separator" }, { label: t("menu.clearAllData"), - click: clearAllData, + click: clearAllDataAndConfirm, }, { role: "quit", label: t("menu.quit", { name }) }, ], diff --git a/apps/renderer/src/modules/auth/LoginModalContent.tsx b/apps/renderer/src/modules/auth/LoginModalContent.tsx index ed31594c2..1d699381f 100644 --- a/apps/renderer/src/modules/auth/LoginModalContent.tsx +++ b/apps/renderer/src/modules/auth/LoginModalContent.tsx @@ -105,7 +105,7 @@ const LoginButtonContent = (props: { children: React.ReactNode; isLoading: boole ) : ( { - signOut() - window.location.href = "/" + if (window.electron) { + tipcClient?.clearAllData().then(() => { + window.location.href = "/" + }) + } else { + signOut() + } }} >