Skip to content

Commit

Permalink
Update main.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed Sep 13, 2023
1 parent 769c3d2 commit 02b57d7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ let globals: {
},

set mainWindowReady(v) {
if (globals.mainWindow) throw new Error('Main window cannot be ready. It does not exist...')
mainWindowReady = v
if (v) readyQueue.forEach(f => onWindowReady(f))
readyQueue = []
Expand All @@ -80,7 +81,7 @@ function send(this: BrowserWindow, ...args: any[]) {
return this.webContents.send(...args)
}

const onWindowReady = (f: (win: BrowserWindow) => any) => (mainWindowReady) ? f(globals.mainWindow) : readyQueue.push(f)
const onWindowReady = (f: (win: BrowserWindow) => any) => (globals.mainWindowReady) ? f(globals.mainWindow) : readyQueue.push(f)


// Pass all important log functions to the application
Expand Down Expand Up @@ -361,7 +362,7 @@ function isValidFile(filepath: string) {

function onFileOpened(_, filepath: string) {
restoreWindow() || initialize(); // Ensure the application is properly visible
onWindowReady((win) => win.webContents.send('fileOpened', filepath))
onWindowReady((win) => send.call(win, 'fileOpened', filepath))
}

if (isWindows && process.argv.length >= 2) {
Expand Down

0 comments on commit 02b57d7

Please sign in to comment.