* Get last focused BrowserWindow or create new if none and callback * @param callback Function to call with the BrowserWindow
(callback: (win: BrowserWindow) => void)
| 213 | * @param callback Function to call with the BrowserWindow |
| 214 | */ |
| 215 | function GetWindow(callback: (win: BrowserWindow) => void) { |
| 216 | const lastWindow = app.getLastFocusedWindow(); |
| 217 | if (lastWindow) { |
| 218 | callback(lastWindow); |
| 219 | } else if (!lastWindow && {}.hasOwnProperty.call(app, 'createWindow')) { |
| 220 | app.createWindow(callback); |
| 221 | } else { |
| 222 | // If createWindow doesn't exist yet ('ready' event was not fired), |
| 223 | // sets his callback to an app.windowCallback property. |
| 224 | app.windowCallback = callback; |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | app.on('open-file', (_event, path) => { |
| 229 | GetWindow((win: BrowserWindow) => { |