fix(invitation): reset app data then logout
Signed-off-by: Innei <i@innei.in>
This commit is contained in:
parent
8f1efb256f
commit
5933ceab63
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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 }) },
|
||||
],
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ const LoginButtonContent = (props: { children: React.ReactNode; isLoading: boole
|
|||
) : (
|
||||
<m.div
|
||||
key="text"
|
||||
className="center"
|
||||
className="center whitespace-nowrap"
|
||||
transition={{
|
||||
type: "spring",
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import { Input } from "~/components/ui/input"
|
|||
import { Tooltip, TooltipContent, TooltipTrigger } from "~/components/ui/tooltip"
|
||||
import { SocialMediaLinks } from "~/constants/social"
|
||||
import { useSignOut } from "~/hooks/biz/useSignOut"
|
||||
import { tipcClient } from "~/lib/client"
|
||||
import { getFetchErrorMessage } from "~/lib/error-parser"
|
||||
import confettiUrl from "~/lottie/confetti.lottie?url"
|
||||
import { useInvitationMutation } from "~/queries/invitations"
|
||||
|
|
@ -139,8 +140,13 @@ export function Component() {
|
|||
variant="ghost"
|
||||
type="button"
|
||||
onClick={() => {
|
||||
signOut()
|
||||
window.location.href = "/"
|
||||
if (window.electron) {
|
||||
tipcClient?.clearAllData().then(() => {
|
||||
window.location.href = "/"
|
||||
})
|
||||
} else {
|
||||
signOut()
|
||||
}
|
||||
}}
|
||||
>
|
||||
<i className="i-mingcute-exit-door-line" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue