@@ -18,6 +18,7 @@ import {
1818 faGear ,
1919 faLink ,
2020 faLock ,
21+ faShare ,
2122 faTrash ,
2223 faUnlock ,
2324 faVideo ,
@@ -42,6 +43,7 @@ import {
4243} from "@/components/VideoThumbnail" ;
4344import { useEffectMutation } from "@/lib/EffectRuntime" ;
4445import { withRpc } from "@/lib/Rpcs" ;
46+ import { usePublicEnv } from "@/utils/public-env" ;
4547import { PasswordDialog } from "../PasswordDialog" ;
4648import { SettingsDialog } from "../SettingsDialog" ;
4749import { SharingDialog } from "../SharingDialog" ;
@@ -121,6 +123,8 @@ export const CapCard = ({
121123 const [ passwordProtected , setPasswordProtected ] = useState (
122124 cap . hasPassword || false ,
123125 ) ;
126+ const { webUrl } = usePublicEnv ( ) ;
127+
124128 const [ copyPressed , setCopyPressed ] = useState ( false ) ;
125129 const [ isDragging , setIsDragging ] = useState ( false ) ;
126130 const [ isSettingsDialogOpen , setIsSettingsDialogOpen ] = useState ( false ) ;
@@ -345,82 +349,82 @@ export const CapCard = ({
345349 "top-2 right-2 flex-col gap-2 z-[51]" ,
346350 ) }
347351 >
348- { isOwner ? (
349- < CapCardButton
350- tooltipContent = "Settings"
351- onClick = { ( e ) => {
352- e . stopPropagation ( ) ;
353- setIsSettingsDialogOpen ( true ) ;
354- } }
355- className = "delay-0"
356- icon = { ( ) => {
357- return < FontAwesomeIcon className = "size-4" icon = { faGear } /> ;
358- } }
359- />
360- ) : (
361- < CapCardButton
362- tooltipContent = "Download Cap"
363- onClick = { ( e ) => {
364- e . stopPropagation ( ) ;
365- handleDownload ( ) ;
366- } }
367- className = "delay-0"
368- icon = { ( ) => (
369- < FontAwesomeIcon className = "size-4" icon = { faDownload } />
370- ) }
371- />
372- ) }
373352 < CapCardButton
374- tooltipContent = "Copy link "
353+ tooltipContent = "Share "
375354 onClick = { ( e ) => {
376355 e . stopPropagation ( ) ;
377- handleCopy (
378- buildEnv . NEXT_PUBLIC_IS_CAP &&
379- NODE_ENV === "production" &&
380- customDomain &&
381- domainVerified
382- ? `https://${ customDomain } /s/${ cap . id } `
383- : buildEnv . NEXT_PUBLIC_IS_CAP && NODE_ENV === "production"
384- ? `https://cap.link/${ cap . id } `
385- : `${ location . origin } /s/${ cap . id } ` ,
386- ) ;
356+ setIsSharingDialogOpen ( true ) ;
387357 } }
388358 className = "delay-0"
389- icon = { ( ) => {
390- return ! copyPressed ? (
391- < FontAwesomeIcon
392- className = "text-gray-12 size-4"
393- icon = { faLink }
394- />
395- ) : (
396- < svg
397- xmlns = "http://www.w3.org/2000/svg"
398- width = "24"
399- height = "24"
400- viewBox = "0 0 24 24"
401- fill = "none"
402- stroke = "currentColor"
403- strokeWidth = "2"
404- strokeLinecap = "round"
405- strokeLinejoin = "round"
406- className = "text-gray-12 size-5 svgpathanimation"
407- >
408- < path d = "M20 6 9 17l-5-5" />
409- </ svg >
410- ) ;
359+ icon = { < FontAwesomeIcon icon = { faShare } /> }
360+ />
361+
362+ < CapCardButton
363+ tooltipContent = "Download Cap"
364+ onClick = { ( e ) => {
365+ e . stopPropagation ( ) ;
366+ handleDownload ( ) ;
411367 } }
368+ className = "delay-0"
369+ icon = { < FontAwesomeIcon icon = { faDownload } /> }
412370 />
413371
372+ { ! isOwner && (
373+ < CapCardButton
374+ tooltipContent = "Copy link"
375+ onClick = { ( e ) => {
376+ e . stopPropagation ( ) ;
377+ handleCopy (
378+ NODE_ENV === "development"
379+ ? `${ webUrl } /s/${ cap . id } `
380+ : buildEnv . NEXT_PUBLIC_IS_CAP &&
381+ customDomain &&
382+ domainVerified
383+ ? `https://${ customDomain } /s/${ cap . id } `
384+ : buildEnv . NEXT_PUBLIC_IS_CAP &&
385+ ! customDomain &&
386+ ! domainVerified
387+ ? `https://cap.link/${ cap . id } `
388+ : `${ webUrl } /s/${ cap . id } ` ,
389+ ) ;
390+ } }
391+ className = "delay-0"
392+ icon = {
393+ < >
394+ { ! copyPressed ? (
395+ < FontAwesomeIcon
396+ className = "text-gray-12 size-4"
397+ icon = { faLink }
398+ />
399+ ) : (
400+ < svg
401+ xmlns = "http://www.w3.org/2000/svg"
402+ width = "24"
403+ height = "24"
404+ viewBox = "0 0 24 24"
405+ fill = "none"
406+ stroke = "currentColor"
407+ strokeWidth = "2"
408+ strokeLinecap = "round"
409+ strokeLinejoin = "round"
410+ className = "text-gray-12 size-5 svgpathanimation"
411+ >
412+ < path d = "M20 6 9 17l-5-5" />
413+ </ svg >
414+ ) }
415+ </ >
416+ }
417+ />
418+ ) }
419+
414420 { isOwner && (
415421 < DropdownMenu modal = { false } onOpenChange = { setIsDropdownOpen } >
416422 < DropdownMenuTrigger asChild suppressHydrationWarning >
417423 < div >
418424 < CapCardButton
419425 tooltipContent = "More options"
420426 className = "delay-75"
421- icon = { ( ) => (
422- < FontAwesomeIcon className = "size-4" icon = { faEllipsis } />
423- ) }
427+ icon = { < FontAwesomeIcon icon = { faEllipsis } /> }
424428 />
425429 </ div >
426430 </ DropdownMenuTrigger >
@@ -432,12 +436,33 @@ export const CapCard = ({
432436 < DropdownMenuItem
433437 onClick = { ( e ) => {
434438 e . stopPropagation ( ) ;
435- handleDownload ( ) ;
439+ setIsSettingsDialogOpen ( true ) ;
440+ } }
441+ className = "flex gap-2 items-center rounded-lg"
442+ >
443+ < FontAwesomeIcon className = "size-3" icon = { faGear } />
444+ < p className = "text-sm text-gray-12" > Settings</ p >
445+ </ DropdownMenuItem >
446+ < DropdownMenuItem
447+ onClick = { ( e ) => {
448+ e . stopPropagation ( ) ;
449+ handleCopy (
450+ buildEnv . NEXT_PUBLIC_IS_CAP &&
451+ NODE_ENV === "production" &&
452+ customDomain &&
453+ domainVerified
454+ ? `https://${ customDomain } /s/${ cap . id } `
455+ : buildEnv . NEXT_PUBLIC_IS_CAP &&
456+ NODE_ENV === "production"
457+ ? `https://cap.link/${ cap . id } `
458+ : `${ location . origin } /s/${ cap . id } ` ,
459+ ) ;
460+ toast . success ( "Link copied to clipboard" ) ;
436461 } }
437462 className = "flex gap-2 items-center rounded-lg"
438463 >
439- < FontAwesomeIcon className = "size-3" icon = { faDownload } />
440- < p className = "text-sm text-gray-12" > Download </ p >
464+ < FontAwesomeIcon className = "size-3" icon = { faLink } />
465+ < p className = "text-sm text-gray-12" > Copy link </ p >
441466 </ DropdownMenuItem >
442467 < DropdownMenuItem
443468 onClick = { ( ) => {
0 commit comments