Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

fix context menu and add open in browser link #234

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions app/context-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,32 @@

const electronContextMenu = require('electron-context-menu')

const { shell } = require('electron')

module.exports = function contextMenu(window, soundcloud) {
// TODO: apply context menu to all windows but only add navigation items to main window
// See https://github.com/sindresorhus/electron-context-menu/pull/25
electronContextMenu({
window,
prepend: (params) => {
prepend: (defaultActions, params) => {
if (params.mediaType == 'none') {
return menuTemplate(soundcloud)
}
}
},
append: (defaultActions, params) => [
{
label: 'Open in Browser',
after: ['copyLink'],
visible: params.linkURL.length !== 0 && params.mediaType === 'none',
click(menuItem) {
shell.openExternal(
menuItem.transform
? menuItem.transform(params.linkURL)
: params.linkURL
)
}
}
]
})
}

Expand Down