Skip to content

Commit

Permalink
Merge pull request #330 from ZIMkaRU/bugfix/fix-11-auto-update-toast-…
Browse files Browse the repository at this point in the history
…width-listeners-added

Fix 11 auto-update-toast:width listeners added
  • Loading branch information
ezewer authored Mar 4, 2024
2 parents 61c3dfc + d02e297 commit 17ec693
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions src/auto-updater/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ const _fireToast = (
WINDOW_EVENT_NAMES.CLOSED,
() => closeAlert(alert)
)
const autoUpdateToastWidthHandler = (event, data) => {
alert.browserWindow?.setBounds({
width: Math.round(data?.width ?? 0)
})
}
const autoUpdateToastRepositionHandler = () => {
const { x, y, width } = win.getContentBounds()
const { width: alWidth } = alert.browserWindow.getContentBounds()

const boundsOpts = {
x: (x + width) - alWidth,
y,
height
}

alert.browserWindow.setBounds(boundsOpts)
}

const bwOptions = {
frame: false,
Expand Down Expand Up @@ -155,6 +172,14 @@ const _fireToast = (
},
didClose: () => {
eventHandlerCtx.removeListener()
ipcMain.removeListener(
'auto-update-toast:width',
autoUpdateToastWidthHandler
)
ipcMain.removeListener(
alert.uid + 'reposition',
autoUpdateToastRepositionHandler
)

didClose(alert)
}
Expand All @@ -169,23 +194,8 @@ const _fireToast = (
sound
)

ipcMain.on('auto-update-toast:width', (event, data) => {
alert.browserWindow?.setBounds({
width: Math.round(data?.width ?? 0)
})
})
ipcMain.on(alert.uid + 'reposition', () => {
const { x, y, width } = win.getContentBounds()
const { width: alWidth } = alert.browserWindow.getContentBounds()

const boundsOpts = {
x: (x + width) - alWidth,
y,
height
}

alert.browserWindow.setBounds(boundsOpts)
})
ipcMain.on('auto-update-toast:width', autoUpdateToastWidthHandler)
ipcMain.on(alert.uid + 'reposition', autoUpdateToastRepositionHandler)

return res
}
Expand Down

0 comments on commit 17ec693

Please sign in to comment.