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.
This commit is contained in:
parent
232841ef5e
commit
cf832d14b4
3 changed files with 23 additions and 11 deletions
|
@ -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<any, {}>((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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 (
|
||||
<li
|
||||
role="link"
|
||||
onClick={handleClick}
|
||||
onContextMenu={handleContextMenu}
|
||||
className={classnames('card claim-preview--tile', {
|
||||
'claim-preview__wrapper--channel': isChannel,
|
||||
})}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { clipboard, remote } from 'electron';
|
||||
import { convertToShareLink } from 'lbry-redux';
|
||||
const isDev = process.env.NODE_ENV !== 'production';
|
||||
|
||||
function injectDevelopmentTemplate(event, templates) {
|
||||
|
@ -105,15 +106,19 @@ export function openSnippetMenu(codeMirror, event) {
|
|||
openContextMenu(event, templates, false, selection);
|
||||
}
|
||||
|
||||
export function openCopyLinkMenu(text, event) {
|
||||
const templates = [
|
||||
{
|
||||
export function openClaimPreviewMenu(claim, event) {
|
||||
let templates = [];
|
||||
|
||||
if (claim) {
|
||||
const shareLink = convertToShareLink(claim.canonical_url || claim.permanent_url);
|
||||
templates.push({
|
||||
label: 'Copy link',
|
||||
click: () => {
|
||||
clipboard.writeText(text);
|
||||
clipboard.writeText(shareLink);
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
openContextMenu(event, templates);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue