From aa9e7cad9e73bd5025cd13d269bb5908d0703465 Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Wed, 12 Jul 2023 12:36:14 +0800 Subject: [PATCH] add to tray --- src/main/mainWindow.ts | 52 +++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 8afa313..24e3289 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -80,6 +80,12 @@ function initTray(win: BrowserWindow) { app.quit(); } }, + { + label: "Reset app", + async click() { + await clearData(win); + } + }, { type: "separator" }, @@ -113,6 +119,29 @@ function initTray(win: BrowserWindow) { }); } +async function clearData(win: BrowserWindow) { + const { response } = await dialog.showMessageBox(win, { + message: "Are you sure you want to reset Vencord Desktop?", + detail: "Vencord Desktop will automatically restart after this operation.", + buttons: ["Yes", "No"], + cancelId: 1, + defaultId: 0, + type: "warning" + }); + + if (response === 1) return; + + win.close(); + + await win.webContents.session.clearStorageData(); + await win.webContents.session.clearCache(); + await win.webContents.session.clearCodeCaches({}); + await rmdir(DATA_DIR); + + app.relaunch(); + app.quit(); +} + function initMenuBar(win: BrowserWindow) { const isWindows = process.platform === "win32"; const isDarwin = process.platform === "darwin"; @@ -133,28 +162,9 @@ function initMenuBar(win: BrowserWindow) { toolTip: "Vencord Desktop will automatically restart after this operation" }, { - label: "Clear data", + label: "Reset app", async click() { - const { response } = await dialog.showMessageBox(win, { - message: "Are you sure you want to reset Vencord Desktop?", - detail: "Vencord Desktop will automatically restart after this operation.", - buttons: ["Yes", "No"], - cancelId: 1, - defaultId: 0, - type: "warning" - }); - - if (response === 1) return; - - win.close(); - - await win.webContents.session.clearStorageData(); - await win.webContents.session.clearCache(); - await win.webContents.session.clearCodeCaches({}); - await rmdir(DATA_DIR); - - app.relaunch(); - app.quit(); + await clearData(win); }, toolTip: "Vencord Desktop will automatically restart after this operation" },