({
post,
comment,
origin,
columns,
column,
row,
parentSelector,
onRequestClose,
...props
}: ShareProps & ModalProps)
| 14 | import { useViewSize, ViewSize } from '../../hooks'; |
| 15 | |
| 16 | export default function ShareModal({ |
| 17 | post, |
| 18 | comment, |
| 19 | origin, |
| 20 | columns, |
| 21 | column, |
| 22 | row, |
| 23 | parentSelector, |
| 24 | onRequestClose, |
| 25 | ...props |
| 26 | }: ShareProps & ModalProps): ReactElement { |
| 27 | const isComment = !!comment; |
| 28 | const isMobile = useViewSize(ViewSize.MobileL); |
| 29 | const { logEvent } = useLogContext(); |
| 30 | const { logOpts } = useContext(ActiveFeedContext); |
| 31 | |
| 32 | const baseLogEvent = (eventName: string, extra?: Record<string, unknown>) => |
| 33 | logEvent( |
| 34 | postLogEvent(eventName, post, { |
| 35 | extra: { |
| 36 | ...extra, |
| 37 | origin, |
| 38 | variant: ExperimentWinner.PostCardShareVersion, |
| 39 | ...(comment && { commentId: comment.id }), |
| 40 | }, |
| 41 | columns, |
| 42 | column, |
| 43 | row, |
| 44 | ...(logOpts && logOpts), |
| 45 | }), |
| 46 | ); |
| 47 | |
| 48 | useEffect(() => { |
| 49 | baseLogEvent('open share'); |
| 50 | |
| 51 | return () => baseLogEvent('close share'); |
| 52 | // @NOTE see https://dailydotdev.atlassian.net/l/cp/dK9h1zoM |
| 53 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 54 | }, []); |
| 55 | |
| 56 | const onSwipedDown = (e: SwipeEventData) => { |
| 57 | const currentTarget = e.event.currentTarget as HTMLElement | null; |
| 58 | |
| 59 | if (!currentTarget) { |
| 60 | return; |
| 61 | } |
| 62 | |
| 63 | const { scrollTop } = currentTarget; |
| 64 | |
| 65 | if (scrollTop === 0) { |
| 66 | onRequestClose(e.event as React.MouseEvent); |
| 67 | } |
| 68 | }; |
| 69 | |
| 70 | const handlers = useSwipeable({ onSwipedDown }); |
| 71 | const squadState = useState<Squad>(); |
| 72 | |
| 73 | return ( |
nothing calls this directly
no test coverage detected