Add showOpenDialog to VesktopNative
This commit is contained in:
parent
b24535483e
commit
044a859e91
3 changed files with 13 additions and 1 deletions
|
@ -4,6 +4,8 @@
|
|||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||
*/
|
||||
|
||||
import * as electron from "electron";
|
||||
|
||||
if (process.platform === "linux") import("./virtmic");
|
||||
|
||||
import { execFile } from "child_process";
|
||||
|
@ -114,6 +116,13 @@ handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
|
|||
return dir;
|
||||
});
|
||||
|
||||
handle(IpcEvents.SHOW_OPEN_DIALOG, async (_, options: electron.OpenDialogOptions) => {
|
||||
const res = await dialog.showOpenDialog(mainWin!, options);
|
||||
if (!res.filePaths.length) return [];
|
||||
|
||||
return res.filePaths;
|
||||
});
|
||||
|
||||
handle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count));
|
||||
|
||||
function readCss() {
|
||||
|
|
|
@ -10,6 +10,7 @@ import type { LiteralUnion } from "type-fest";
|
|||
|
||||
import { IpcEvents } from "../shared/IpcEvents";
|
||||
import { invoke, sendSync } from "./typedIpc";
|
||||
import electron from "electron";
|
||||
|
||||
type SpellCheckerResultCallback = (word: string, suggestions: string[]) => void;
|
||||
|
||||
|
@ -33,7 +34,8 @@ export const VesktopNative = {
|
|||
},
|
||||
fileManager: {
|
||||
showItemInFolder: (path: string) => invoke<void>(IpcEvents.SHOW_ITEM_IN_FOLDER, path),
|
||||
selectVencordDir: () => invoke<LiteralUnion<"cancelled" | "invalid", string>>(IpcEvents.SELECT_VENCORD_DIR)
|
||||
selectVencordDir: () => invoke<LiteralUnion<"cancelled" | "invalid", string>>(IpcEvents.SELECT_VENCORD_DIR),
|
||||
showOpenDialog: (options: electron.OpenDialogOptions) => invoke<string[]>(IpcEvents.SHOW_OPEN_DIALOG, options)
|
||||
},
|
||||
settings: {
|
||||
get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS),
|
||||
|
|
|
@ -20,6 +20,7 @@ export const enum IpcEvents {
|
|||
MAXIMIZE = "VCD_MAXIMIZE",
|
||||
|
||||
SHOW_ITEM_IN_FOLDER = "VCD_SHOW_ITEM_IN_FOLDER",
|
||||
SHOW_OPEN_DIALOG = "VCD_SHOW_OPEN_DIALOG",
|
||||
GET_SETTINGS = "VCD_GET_SETTINGS",
|
||||
SET_SETTINGS = "VCD_SET_SETTINGS",
|
||||
|
||||
|
|
Reference in a new issue