import { Window } from "../window" ; import { workspace_window } from "../../global" ; import { BrowserWindow , ipcMain } from "electron" ; export class EnterPasswordWindow extends Window { private password : string ; private readonly title : string ; private readonly description : string ; constructor ( title , description ) { super ( ) ; this . password = null ; this . title = title ; this . description = description ; } public show ( ) { const zis = this ; return new Promise < string > ( ( resolve , reject ) => { this . openWindow ( 500 , 180 , "enter_password.html" , null , { resizable : false , modal : true , autoHideMenuBar : true , parent : workspace_window . browserWindow } , ( browserWindow ) => { browserWindow . webContents . send ( 'init' , this . title , this . description ) ; } ) ; ipcMain . on ( "updated" , ( event , password ) => { zis . password = password ; } ) ; this . onClosed = ( ) => { ipcMain . removeAllListeners ( "updated" ) ; resolve ( this . password ) ; } ; } ) ; } }