Skip to content

Commit

Permalink
refactor: tray click events (#1766)
Browse files Browse the repository at this point in the history
- avoid random `TypeError: event.preventDefault is not a function`  (closes #1762)
- double-click opens webui (closes #17649)
  • Loading branch information
lidel committed Feb 23, 2021
1 parent 71756f5 commit 1e00334
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,20 @@ module.exports = function (ctx) {
ctx.launchWebUI('/files', { focus: false })
})

const popupMenu = (event) => {
// https://github.com/ipfs-shipyard/ipfs-desktop/issues/1762 ¯\_(ツ)_/¯
if (event && typeof event.preventDefault === 'function') event.preventDefault()

tray.popUpContextMenu()
}

if (!IS_MAC) {
// Show the context menu on left click on other
// platforms than macOS.
tray.on('click', event => {
event.preventDefault()
tray.popUpContextMenu()
})
tray.on('click', popupMenu)
}
tray.on('right-click', popupMenu)
tray.on('double-click', () => ctx.launchWebUI('/'))

const setupMenu = () => {
menu = buildMenu(ctx)
Expand Down

0 comments on commit 1e00334

Please sign in to comment.