diff --git a/src/main.ts b/src/main.ts index b615e30..0603353 100644 --- a/src/main.ts +++ b/src/main.ts @@ -137,7 +137,7 @@ if (!gotTheLock) { loadBounds(mainWindow); initializeSettings(mainWindow, view); initializePlayer(view); - initializeDownloads(view); + initializeDownloads(mainView, view); createHistoryHandles(view); createKeyboardHandles(view); diff --git a/src/main/downloads.ts b/src/main/downloads.ts index d329069..49ddd26 100644 --- a/src/main/downloads.ts +++ b/src/main/downloads.ts @@ -14,7 +14,7 @@ const containsWarning = (stdout: string) => .split('\n') .some((l) => warningMessages.some((error) => l.endsWith(error))); -const download = async (url: string, view: WebContentsView) => { +const download = async (url: string, mainView: WebContentsView) => { try { const { stdout, stderr } = await exec(`deemix ${url}`); let execStatus: ExecStatus = 'Success'; @@ -22,10 +22,16 @@ const download = async (url: string, view: WebContentsView) => { execStatus = 'Warning'; } - view.webContents.send(DOWNLOADS_FINISHED, execStatus, url, stdout, stderr); + mainView.webContents.send( + DOWNLOADS_FINISHED, + execStatus, + url, + stdout, + stderr + ); } catch (e) { const execException = e as ExecException; - view.webContents.send( + mainView.webContents.send( DOWNLOADS_FINISHED, 'Error', url, @@ -35,12 +41,18 @@ const download = async (url: string, view: WebContentsView) => { } }; -const createDownloadHandles = (view: WebContentsView) => { +const createDownloadHandles = ( + mainView: WebContentsView, + view: WebContentsView +) => { ipcMain.on(DOWNLOADS_DOWNLOAD, () => { - download(view.webContents.getURL(), view); + download(view.webContents.getURL(), mainView); }); }; -export const initializeDownloads = (view: WebContentsView) => { - createDownloadHandles(view); +export const initializeDownloads = ( + mainView: WebContentsView, + view: WebContentsView +) => { + createDownloadHandles(mainView, view); };