Open History to see the last commit
1import { type BrowserWindow, dialog } from "electron";
2
3const CONFIRM_BUTTON_INDEX = 1;
4
5export async function showDesktopConfirmDialog(
6 message: string,
7 ownerWindow: BrowserWindow | null,
8): Promise<boolean> {
9 const normalizedMessage = message.trim();
10 if (normalizedMessage.length === 0) {
11 return false;
12 }
13
14 const options = {
15 type: "question" as const,
16 buttons: ["No", "Yes"],
17 defaultId: CONFIRM_BUTTON_INDEX,
18 cancelId: 0,
19 noLink: true,
20 message: normalizedMessage,
21 };
22 const result = ownerWindow
23 ? await dialog.showMessageBox(ownerWindow, options)
24 : await dialog.showMessageBox(options);
25 return result.response === CONFIRM_BUTTON_INDEX;
26}