From cf832d14b4ce82078ec468f9e63c59a6d49f218a Mon Sep 17 00:00:00 2001 From: infiinte-persistence Date: Wed, 17 Feb 2021 13:49:05 +0800 Subject: [PATCH] Make both claimPreview and claimPreviewTile use the same context-menu function. Consolidated into `openClaimPreviewMenu`. We'll only update that function next time for context-menu additions. --- ui/component/claimPreview/view.jsx | 7 ++----- ui/component/claimPreviewTile/view.jsx | 10 ++++++++++ ui/util/context-menu.js | 17 +++++++++++------ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/ui/component/claimPreview/view.jsx b/ui/component/claimPreview/view.jsx index cd6b6d8d9..32df52b25 100644 --- a/ui/component/claimPreview/view.jsx +++ b/ui/component/claimPreview/view.jsx @@ -5,7 +5,7 @@ import { NavLink, withRouter } from 'react-router-dom'; import classnames from 'classnames'; import { SIMPLE_SITE } from 'config'; import { parseURI, convertToShareLink } from 'lbry-redux'; -import { openCopyLinkMenu } from 'util/context-menu'; +import { openClaimPreviewMenu } from 'util/context-menu'; import { formatLbryUrlForWeb } from 'util/url'; import { isEmpty } from 'util/object'; import FileThumbnail from 'component/fileThumbnail'; @@ -193,10 +193,7 @@ const ClaimPreview = forwardRef((props: Props, ref: any) => { // @if TARGET='app' e.preventDefault(); e.stopPropagation(); - if (claim) { - const shareLink = convertToShareLink(claim.canonical_url || claim.permanent_url); - openCopyLinkMenu(shareLink.replace(/#/g, ':'), e); - } + openClaimPreviewMenu(claim, e); // @endif } diff --git a/ui/component/claimPreviewTile/view.jsx b/ui/component/claimPreviewTile/view.jsx index 9be6da5e3..932ce040c 100644 --- a/ui/component/claimPreviewTile/view.jsx +++ b/ui/component/claimPreviewTile/view.jsx @@ -14,6 +14,7 @@ import { parseURI } from 'lbry-redux'; import FileProperties from 'component/fileProperties'; import FileDownloadLink from 'component/fileDownloadLink'; import ClaimRepostAuthor from 'component/claimRepostAuthor'; +import { openClaimPreviewMenu } from 'util/context-menu'; type Props = { uri: string, @@ -150,10 +151,19 @@ function ClaimPreviewTile(props: Props) { ); } + function handleContextMenu(e) { + // @if TARGET='app' + e.preventDefault(); + e.stopPropagation(); + openClaimPreviewMenu(claim, e); + // @endif + } + return (
  • { - clipboard.writeText(text); + clipboard.writeText(shareLink); }, - }, - ]; + }); + } + openContextMenu(event, templates); }