MCPcopy Create free account
hub / github.com/dailydotdev/apps / PostMenuOptions

Function PostMenuOptions

packages/shared/src/components/post/PostMenuOptions.tsx:30–81  ·  view source on GitHub ↗
({
  post,
  origin,
  buttonSize,
  menuTriggerClassName,
}: PostMenuOptionsProps)

Source from the content-addressed store, hash-verified

28}
29
30export function PostMenuOptions({
31 post,
32 origin,
33 buttonSize,
34 menuTriggerClassName,
35}: PostMenuOptionsProps): ReactElement {
36 const [linkCopied, copyLink] = useCopyPostLink();
37 const { logEvent } = useLogContext();
38
39 const onCopyLink = () => {
40 logEvent(
41 postLogEvent(LogEvent.SharePost, post, {
42 extra: { provider: ShareProvider.CopyLink, origin },
43 }),
44 );
45 // `shorten`, not an awaited short URL: awaiting the shortener first ends
46 // the task that handled the click, and Safari refuses the write after
47 // that. The permalink lands immediately and the tracked link replaces it.
48 copyLink({
49 link: post.commentsPermalink,
50 shorten: true,
51 cid: ReferralCampaignKey.SharePost,
52 });
53 };
54
55 return (
56 <>
57 {/* Beside the menu rather than in any one header: every post type builds
58 its own header, and this is the only control all of them share. */}
59 {post && (
60 <Tooltip side="bottom" content="Copy link">
61 <Button
62 aria-label="Copy link"
63 className="hidden laptop:flex"
64 icon={<CopyStateIcon copied={linkCopied} icon={LinkIcon} />}
65 onClick={onCopyLink}
66 size={buttonSize}
67 type="button"
68 variant={ButtonVariant.Tertiary}
69 />
70 </Tooltip>
71 )}
72 <PostOptionButton
73 post={post}
74 size={buttonSize}
75 triggerClassName={menuTriggerClassName}
76 variant={ButtonVariant.Tertiary}
77 origin={origin}
78 />
79 </>
80 );
81}

Callers

nothing calls this directly

Calls 2

useCopyPostLinkFunction · 0.90
useLogContextFunction · 0.90

Tested by

no test coverage detected