// Metro module 8169 (f8170). import { useCallback, useMemo } from "react"; import ICYMIStore from "../../../icymi/ICYMIStore"; import ChannelStore from "../../../../stores/ChannelStore"; import MessageStore from "../../../../stores/MessageStore"; import MessagePreviewStore from "../../../../stores/native/MessagePreviewStore"; import { AnalyticsSections, GIF_RE_IOS, MediaType } from "../../../../Constants"; import { EXPLICIT_MEDIA_FALSE_POSITIVE_ACTION_SHEET_KEY } from "../../../explicit_media_redaction/ExplicitMediaRedactionConstants"; import { useStateFromStores } from "../../../../_bundle/defaultAreStatesEqual"; import { shouldAgeVerifyForExplicitMedia } from "../../../explicit_media_redaction/ExplicitMediaRedactionUtils"; import { getAttachmentObscurityProps } from "../../../messages/native/renderer/ExplicitMediaUtils"; import ActionSheetActionCreators from "../../../action_sheet/native/ActionSheetActionCreators"; import { downloadMediaAssetWithContentType, getVideoSourceType, VideoSourceType } from "../MediaSourceUtil"; import { urlMatchesFileExtension } from "../../../messages/MediaFormatTesters"; import { showShareActionSheet } from "../../../action_sheet/native/showShareActionSheet"; import { MediaViewerAnalytics } from "../../MediaViewerAnalyticsManager"; import { handleClick } from "../../../../utils/MaskedLinkUtils"; import Linking from "../../../../lib/native/Linking"; import { openForwardModal } from "../../../forwarding/native/ForwardModalUtils"; import { transitionToMessage } from "../../../routing/transitionToChannel"; import { getChatLayout } from "../../../chat/native/useChatLayout"; import { useCanForwardMessage } from "../../../forwarding/canForwardMessage"; import { DownloadIcon } from "../../../../design/components/Icon/native/redesign/generated/DownloadIcon"; import { intl, t } from "../../../../intl/index.native"; import ForwardingIcon from "../../../forwarding/native/ForwardingIcon"; import { ShareIcon } from "../../../../design/components/Icon/native/redesign/generated/ShareIcon"; import { WindowLaunchIcon } from "../../../../design/components/Icon/native/redesign/generated/WindowLaunchIcon"; import { ChatArrowRightIcon } from "../../../../design/components/Icon/native/redesign/generated/ChatArrowRightIcon"; import { ImageWarningIcon } from "../../../../design/components/Icon/native/redesign/generated/ImageWarningIcon"; import { ActionSheet } from "../../../../design/components/Sheet/native/ActionSheet.native"; import { ActionSheetRow } from "../../../../design/components/Sheet/native/ActionSheetRow.native"; const useMediaShareActions = function useMediaShareActions({ source, disableDownload, shareable }) { let obscure, callback, callback2, callback3, callback4, callback5, callback6, c16300_13, videoSourceType; obscure = void 0; callback = void 0; callback2 = void 0; callback3 = void 0; callback4 = void 0; callback5 = void 0; callback6 = void 0; c16300_13 = void 0; videoSourceType = void 0; const { channelId, messageId } = source; const stateFromStores = useStateFromStores([MessageStore, ICYMIStore, MessagePreviewStore], () => { const r1 = channelId == null; let r2 = null; if (!r1) { const r8 = messageId == null; r2 = null; if (!r8) { let r10 = MessageStore.getMessage(channelId, messageId); if (r10 == null) { r10 = MessagePreviewStore.getMessage(messageId); } if (r10 == null) { r10 = ICYMIStore.getMessage(messageId); } r2 = r10; } } return r2; }, [channelId, messageId]); obscure = getAttachmentObscurityProps({ attachment: source, shouldObscureSpoiler: true, enabledContentHarmTypeFlags: 0, shouldAgeVerify: shouldAgeVerifyForExplicitMedia() }).obscure; callback = useCallback(() => { ActionSheetActionCreators.hideActionSheet(); if (source.videoURI != null) { downloadMediaAssetWithContentType(source.videoURI, MediaType.VIDEO, source.contentType); } else if (source.sourceURI != null) { downloadMediaAssetWithContentType(source.sourceURI, urlMatchesFileExtension(source.sourceURI, GIF_RE_IOS) ? MediaType.GIF : MediaType.IMAGE, source.contentType); } }, [source]); callback2 = useCallback(() => { ActionSheetActionCreators.hideActionSheet(); showShareActionSheet({ source }, AnalyticsSections.MEDIA_VIEWER); MediaViewerAnalytics.trackMediaViewerShareButtonTapped(); }, [source]); callback3 = useCallback(() => { ActionSheetActionCreators.hideActionSheet(); if (source.sourceURI != null) { handleClick({ href: source.sourceURI, onConfirm: () => { Linking.openURL(source.sourceURI); } }); } }, [source]); callback4 = useCallback(() => { ActionSheetActionCreators.hideActionSheet(); if (stateFromStores != null) { if (source.accessoryType !== "embed") { const attachmentId = source.attachmentId; if (attachmentId != null) { openForwardModal({ message: stateFromStores, source: "media-viewer", initialSelectedDestinations: void 0, forwardOptions: { onlyAttachmentIds: [attachmentId] } }); } } else { openForwardModal({ message: stateFromStores, source: "media-viewer", initialSelectedDestinations: void 0, forwardOptions: { onlyEmbedIndices: [source.mediaIndex] } }); } } }, [stateFromStores, source]); callback5 = useCallback(() => { ActionSheetActionCreators.hideActionSheet(); if (ChannelStore.getChannel(source.channelId) != null && source.channelId != null && source.messageId != null) { const { channelId: channelId2, messageId: messageId2 } = source; const isChatLockedOpen = getChatLayout().isChatLockedOpen; transitionToMessage(channelId2, messageId2, { navigationReplace: isChatLockedOpen ? void 0 : !isChatLockedOpen }); } }, [source]); callback6 = useCallback(() => { ActionSheetActionCreators.hideActionSheet(); const attachmentId = source.attachmentId; if (attachmentId != null && source.channelId != null && source.messageId != null) { ActionSheetActionCreators.openLazy(import("../../../explicit_media_redaction/native/false_positive_reporting/ExplicitMediaObscuredFalsePositiveActionSheet"), EXPLICIT_MEDIA_FALSE_POSITIVE_ACTION_SHEET_KEY, { messageId: source.messageId, channelId: source.channelId, attachmentId }); } }, [source]); const r61 = useCanForwardMessage(stateFromStores) && (source.attachmentId != null || source.accessoryType === "embed"); c16300_13 = r61; videoSourceType = getVideoSourceType(source); return useMemo(() => { const r12 = disableDownload !== true && videoSourceType !== VideoSourceType.WEB_FILE_IFRAME; const r19 = []; if (r12) { r19.push({ IconComponent: DownloadIcon, label: intl.string(t["R3BPH+"]), action: callback }); } if (c16300_13) { r19.push({ IconComponent: ForwardingIcon, label: intl.string(t.I3ltXO), action: callback4 }); } if (shareable) { r19.push({ IconComponent: ShareIcon, label: intl.string(t.RDE0Sc), action: callback2 }); } r19.push({ IconComponent: WindowLaunchIcon, label: intl.string(t.q5jLJB), action: callback3 }); if (source.channelId != null && source.messageId != null) { r19.push({ IconComponent: ChatArrowRightIcon, label: intl.string(t["+TSRGD"]), action: callback5 }); } if (obscure) { r19.push({ IconComponent: ImageWarningIcon, label: intl.string(t.ZH7P2h), action: callback6 }); } return r19; }, [disableDownload, callback4, callback5, callback3, callback6, callback, callback2, obscure, shareable, r61, videoSourceType, source.channelId, source.messageId]); }; export default function MediaShareActionSheet(props) { return {useMediaShareActions({ source: props.source, disableDownload: props.disableDownload, shareable: props.shareable }).map((item, index) => } onPress={item.action} label={item.label} />)} ; }; export { useMediaShareActions };