@@ -6,8 +6,6 @@ import * as Schema from "effect/Schema";
66
77import * as Electron from "electron" ;
88
9- const CONFIRM_BUTTON_INDEX = 1 ;
10-
119export class ElectronDialogPickFolderError extends Schema . TaggedErrorClass < ElectronDialogPickFolderError > ( ) (
1210 "ElectronDialogPickFolderError" ,
1311 {
@@ -38,20 +36,6 @@ export class ElectronDialogPickFilesError extends Schema.TaggedErrorClass<Electr
3836 }
3937}
4038
41- export class ElectronDialogConfirmError extends Schema . TaggedErrorClass < ElectronDialogConfirmError > ( ) (
42- "ElectronDialogConfirmError" ,
43- {
44- ownerWindowId : Schema . NullOr ( Schema . Number ) ,
45- promptLength : Schema . Number ,
46- cause : Schema . Defect ( ) ,
47- } ,
48- ) {
49- override get message ( ) : string {
50- const owner = this . ownerWindowId === null ? "the application" : `window ${ this . ownerWindowId } ` ;
51- return `Failed to open an Electron confirmation dialog for ${ owner } with a ${ this . promptLength } -character prompt.` ;
52- }
53- }
54-
5539export class ElectronDialogShowMessageBoxError extends Schema . TaggedErrorClass < ElectronDialogShowMessageBoxError > ( ) (
5640 "ElectronDialogShowMessageBoxError" ,
5741 {
@@ -85,7 +69,6 @@ export class ElectronDialogShowErrorBoxError extends Schema.TaggedErrorClass<Ele
8569export const ElectronDialogError = Schema . Union ( [
8670 ElectronDialogPickFolderError ,
8771 ElectronDialogPickFilesError ,
88- ElectronDialogConfirmError ,
8972 ElectronDialogShowMessageBoxError ,
9073 ElectronDialogShowErrorBoxError ,
9174] ) ;
@@ -103,11 +86,6 @@ export interface ElectronDialogPickFilesInput {
10386 readonly filters : readonly Electron . FileFilter [ ] ;
10487}
10588
106- export interface ElectronDialogConfirmInput {
107- readonly owner : Option . Option < Electron . BrowserWindow > ;
108- readonly message : string ;
109- }
110-
11189export class ElectronDialog extends Context . Service <
11290 ElectronDialog ,
11391 {
@@ -117,9 +95,6 @@ export class ElectronDialog extends Context.Service<
11795 readonly pickFiles : (
11896 input : ElectronDialogPickFilesInput ,
11997 ) => Effect . Effect < readonly string [ ] , ElectronDialogPickFilesError > ;
120- readonly confirm : (
121- input : ElectronDialogConfirmInput ,
122- ) => Effect . Effect < boolean , ElectronDialogConfirmError > ;
12398 readonly showMessageBox : (
12499 options : Electron . MessageBoxOptions ,
125100 ) => Effect . Effect < Electron . MessageBoxReturnValue , ElectronDialogShowMessageBoxError > ;
@@ -188,39 +163,6 @@ export const make = ElectronDialog.of({
188163 } ) ;
189164 return result . canceled ? [ ] : result . filePaths ;
190165 } ) ,
191- confirm : Effect . fn ( "desktop.electron.dialog.confirm" ) ( function * ( input ) {
192- const normalizedMessage = input . message . trim ( ) ;
193- if ( normalizedMessage . length === 0 ) {
194- return false ;
195- }
196-
197- const options = {
198- type : "question" as const ,
199- buttons : [ "No" , "Yes" ] ,
200- defaultId : 0 ,
201- cancelId : 0 ,
202- noLink : true ,
203- message : normalizedMessage ,
204- } ;
205- const ownerWindowId = Option . match ( input . owner , {
206- onNone : ( ) => null ,
207- onSome : ( owner ) => owner . id ,
208- } ) ;
209- const result = yield * Effect . tryPromise ( {
210- try : ( ) =>
211- Option . match ( input . owner , {
212- onNone : ( ) => Electron . dialog . showMessageBox ( options ) ,
213- onSome : ( owner ) => Electron . dialog . showMessageBox ( owner , options ) ,
214- } ) ,
215- catch : ( cause ) =>
216- new ElectronDialogConfirmError ( {
217- ownerWindowId,
218- promptLength : normalizedMessage . length ,
219- cause,
220- } ) ,
221- } ) ;
222- return result . response === CONFIRM_BUTTON_INDEX ;
223- } ) ,
224166 showMessageBox : ( options ) =>
225167 Effect . tryPromise ( {
226168 try : ( ) => Electron . dialog . showMessageBox ( options ) ,
0 commit comments