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

Function ShareLink

packages/shared/src/components/post/write/ShareLink.tsx:41–218  ·  view source on GitHub ↗
({
  squad,
  className,
  onPostSuccess,
  post,
  moderated,
  isPostingOnMySource = false,
  initialUrl,
  initialCommentary,
}: ShareLinkProps)

Source from the content-addressed store, hash-verified

39};
40
41export function ShareLink({
42 squad,
43 className,
44 onPostSuccess,
45 post,
46 moderated,
47 isPostingOnMySource = false,
48 initialUrl,
49 initialCommentary,
50}: ShareLinkProps): ReactElement {
51 const fetchedPost = post || moderated;
52 const isCreatingPost = !fetchedPost;
53
54 const { showPrompt } = usePrompt();
55 const { push } = useRouter();
56 const { displayToast } = useToastNotification();
57 const { onSubmitForm, isPosting: isPendingCreation } = useWritePostContext();
58
59 const [commentary, setCommentary] = useState(() => {
60 if (fetchedPost?.sharedPost) {
61 return fetchedPost.title;
62 }
63
64 if (fetchedPost) {
65 return fetchedPost.content;
66 }
67
68 return initialCommentary ?? '';
69 });
70
71 useEffect(() => {
72 if (!fetchedPost?.sharedPost) {
73 return;
74 }
75
76 if (fetchedPost.title !== fetchedPost.sharedPost.title) {
77 return;
78 }
79
80 if (commentary !== fetchedPost.sharedPost.title) {
81 return;
82 }
83
84 setCommentary('');
85 }, [commentary, fetchedPost]);
86 const {
87 getLinkPreview,
88 isLoadingPreview,
89 preview,
90 isPosting,
91 onUpdateSharePost,
92 onUpdatePreview,
93 } = usePostToSquad({
94 onPostSuccess,
95 initialPreview:
96 fetchedPost?.sharedPost ||
97 (moderated && {
98 url: moderated.externalLink,

Callers

nothing calls this directly

Calls 6

usePromptFunction · 0.90
useToastNotificationFunction · 0.90
useWritePostContextFunction · 0.90
usePostToSquadFunction · 0.90
useSourcePostModerationFunction · 0.85
useRouterFunction · 0.50

Tested by

no test coverage detected