Skip to content

Commit

Permalink
always show copy link when right clicking a link in a message (#3187)
Browse files Browse the repository at this point in the history
closes #3184
  • Loading branch information
Simon-Laux authored Apr 13, 2023
1 parent cb18f87 commit 49e57b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- fix show error messages when starting a video chat
- don't show video chat in attachment menu when the feature is turned off
- fix "Always Load Remote Images" should be hidden for contact requests #3180
- always show copy link when right clicking a link in a message #3184

<a id="1_36_1"></a>

Expand Down
16 changes: 10 additions & 6 deletions src/renderer/components/message/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ function buildContextMenu(
throw new Error('cannot show context menu for undefined message')
}

const isLink = clickTarget && !clickTarget.getAttribute('x-not-a-link')
const isLink = Boolean(
clickTarget && !clickTarget.getAttribute('x-not-a-link')
)
const email = clickTarget?.getAttribute('x-target-email')
const link: string =
clickTarget?.getAttribute('x-target-url') || clickTarget?.href || ''
Expand Down Expand Up @@ -174,11 +176,6 @@ function buildContextMenu(
runtime.writeClipboardText(selectedText as string)
},
}
} else if (link !== '' && isLink) {
copy_item = {
label: tx('menu_copy_link_to_clipboard'),
action: () => runtime.writeClipboardText(link),
}
} else if (email) {
copy_item = {
label: tx('menu_copy_email_to_clipboard'),
Expand All @@ -205,6 +202,13 @@ function buildContextMenu(
label: tx('reply_privately'),
action: privateReply.bind(null, message),
},
// copy link
link !== '' &&
isLink && {
label: tx('menu_copy_link_to_clipboard'),
action: () => runtime.writeClipboardText(link),
},
// copy item (selection or all text)
text !== '' && copy_item,
// Copy image
showCopyImage && {
Expand Down

0 comments on commit 49e57b4

Please sign in to comment.