Address issues
This commit is contained in:
parent
7d23d7db26
commit
f1ee4a8e99
1 changed files with 15 additions and 9 deletions
|
@ -13,7 +13,7 @@ import {
|
||||||
MenuItemConstructorOptions,
|
MenuItemConstructorOptions,
|
||||||
Tray
|
Tray
|
||||||
} from "electron";
|
} from "electron";
|
||||||
import { rmdir } from "fs/promises";
|
import { rm } from "fs/promises";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { IpcEvents } from "shared/IpcEvents";
|
import { IpcEvents } from "shared/IpcEvents";
|
||||||
import { isTruthy } from "shared/utils/guards";
|
import { isTruthy } from "shared/utils/guards";
|
||||||
|
@ -119,24 +119,30 @@ function initTray(win: BrowserWindow) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const enum MessageBoxChoice {
|
||||||
|
Default,
|
||||||
|
Cancel
|
||||||
|
}
|
||||||
|
|
||||||
async function clearData(win: BrowserWindow) {
|
async function clearData(win: BrowserWindow) {
|
||||||
const { response } = await dialog.showMessageBox(win, {
|
const { response } = await dialog.showMessageBox(win, {
|
||||||
message: "Are you sure you want to reset Vencord Desktop?",
|
message:
|
||||||
detail: "Vencord Desktop will automatically restart after this operation.",
|
"Are you sure you want to reset Vesktop? This will log you out, clear caches and reset all your settings",
|
||||||
|
detail: "Vesktop will automatically restart after this operation.",
|
||||||
buttons: ["Yes", "No"],
|
buttons: ["Yes", "No"],
|
||||||
cancelId: 1,
|
cancelId: MessageBoxChoice.Cancel,
|
||||||
defaultId: 0,
|
defaultId: MessageBoxChoice.Default,
|
||||||
type: "warning"
|
type: "warning"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response === 1) return;
|
if (response === MessageBoxChoice.Cancel) return;
|
||||||
|
|
||||||
win.close();
|
win.close();
|
||||||
|
|
||||||
await win.webContents.session.clearStorageData();
|
await win.webContents.session.clearStorageData();
|
||||||
await win.webContents.session.clearCache();
|
await win.webContents.session.clearCache();
|
||||||
await win.webContents.session.clearCodeCaches({});
|
await win.webContents.session.clearCodeCaches({});
|
||||||
await rmdir(DATA_DIR);
|
await rm(DATA_DIR, { force: true, recursive: true });
|
||||||
|
|
||||||
app.relaunch();
|
app.relaunch();
|
||||||
app.quit();
|
app.quit();
|
||||||
|
@ -162,11 +168,11 @@ function initMenuBar(win: BrowserWindow) {
|
||||||
toolTip: "Vesktop will automatically restart after this operation"
|
toolTip: "Vesktop will automatically restart after this operation"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Reset app",
|
label: "Reset Vesktop",
|
||||||
async click() {
|
async click() {
|
||||||
await clearData(win);
|
await clearData(win);
|
||||||
},
|
},
|
||||||
toolTip: "Vencord Desktop will automatically restart after this operation"
|
toolTip: "Vesktop will automatically restart after this operation"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Relaunch",
|
label: "Relaunch",
|
||||||
|
|
Reference in a new issue