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

Function onShareOrCopy

packages/shared/src/hooks/useShareOrCopyLink.ts:27–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25 const { getShortUrl } = useGetShortUrl();
26
27 const onShareOrCopy: CopyNotifyFunction = async () => {
28 const shortLink = cid ? await getShortUrl(link, cid) : link;
29 const logShareEvent = (provider: ShareProvider): void => {
30 if (!logObject) {
31 return;
32 }
33
34 logEvent(logObject(provider));
35 };
36
37 if (shouldUseNativeShare()) {
38 try {
39 await navigator.share({
40 text: `${text}\n${shortLink}`,
41 });
42 logShareEvent(ShareProvider.Native);
43 } catch (err) {
44 // Do nothing
45 }
46 } else {
47 logShareEvent(ShareProvider.CopyLink);
48 copyLink({ link: shortLink });
49 }
50 };
51
52 return [copying, onShareOrCopy];
53}

Callers

nothing calls this directly

Calls 2

shouldUseNativeShareFunction · 0.90
logShareEventFunction · 0.70

Tested by

no test coverage detected