// Metro module 9563 (f9564). import PendingReplyStore from "../../../replies/PendingReplyStore"; import { isMessageComponentsV2 } from "../../../../records/MessageRecord"; import EditMessageStore from "../../../../stores/EditMessageStore"; import UploadStore from "../../../../stores/UploadStore"; import UserStore from "../../../../stores/UserStore"; import SendMessageOptionsStore from "../../SendMessageOptionsStore"; import { AnalyticEvents, AnalyticsObjects, AnalyticsPages, AnalyticsSections, ComponentActions, GIF_RE_IOS, MediaType, MessageStates, MessageTypes } from "../../../../Constants"; import { isStaticChannelRoute } from "../../../channel/ChannelConstants"; import { EXPLICIT_MEDIA_FALSE_POSITIVE_ACTION_SHEET_KEY } from "../../../explicit_media_redaction/ExplicitMediaRedactionConstants"; import UserUtils from "../../../../utils/UserUtils"; import SnowflakeUtils from "../../../../utils/SnowflakeUtils"; import { deletePendingReply } from "../../../replies/PendingReplyActionCreators"; import { openCreateForumPostModal } from "../../../forums/native/composer/ForumComposerModalActionCreators"; import AnalyticsLocation from "../../../app_analytics/AnalyticsLocation"; import AnalyticsUtils from "../../../../utils/AnalyticsUtils"; import MessageActionCreators from "../../../../actions/MessageActionCreators"; import AlertActionCreators from "../../../../actions/AlertActionCreators"; import { intl, t } from "../../../../intl/index.native"; import PublishModal from "../../../action_sheet/native/components/PublishModal"; import LongPressMessageChatItemPreview from "./LongPressMessageChatItemPreview"; import ChannelPinActionCreators from "../../../../actions/ChannelPinActionCreators"; import { AccessibilityAnnouncer } from "../../../../_bundle/Module3902"; import MessageQueue from "../../../../lib/MessageQueue"; import retrySendMessage_native from "../../retrySendMessage.native"; import ThreadActionCreators from "../../../threads/ThreadActionCreators"; import { navigateToCreateThread, navigateToContextMenuCommands } from "../../../main_tabs_v2/helpers/NavigationRouteUtils.native"; import { transitionToGuild } from "../../../routing/router_utils"; import { getAllTextDisplayContent } from "../../../interaction_components/InteractionComponentUtils"; import { copy } from "../../../../utils/ClipboardUtils.native"; import { presentLinkCopied, presentMessageIdCopied, presentMessageCopied, presentGifSaved, presentImageSaved, presentVideoSaved } from "../../../toast/native/ToastUtils"; import { getChannelPermalink } from "../../../../utils/ChannelUtils"; import ChannelActionCreators from "../../../../actions/ChannelActionCreators"; import markUnread from "../../markUnread"; import { urlMatchesFileExtension } from "../../MediaFormatTesters"; import URLUtils from "../../../../utils/URLUtils"; import { isAttachmentUrl, maybeRefreshAttachmentUrl } from "../../SignedAttachmentLinkUtils"; import { downloadMediaAssetWithContentType } from "../../../media_viewer/native/MediaSourceUtil"; import { handleClick } from "../../../../utils/MaskedLinkUtils"; import { getHostname } from "../../../../stores/MaskedLinkStoreMethodsAdditional.native"; import { messageHasObscurableMedia } from "../../../explicit_media_redaction/ObscuredMediaUtils"; import ActionSheetActionCreators from "../../../action_sheet/native/ActionSheetActionCreators"; import { canReportMessage } from "../../../../utils/ReportUtils"; import { showReportToModMessageModal, showReportModalForMessage } from "../../../in_app_reports/ReportModals"; import ReportToMod_messages from "../../../report_to_mod/ReportToMod.messages"; import { canReportMessageToMods } from "../../../report_to_mod/ReportToModUtils"; import { transitionToMessage } from "../../../routing/transitionToChannel"; import showUserProfileActionSheet from "../../../user_profile/native/showUserProfileActionSheet"; import AppAnalyticsUtils from "../../../app_analytics/AppAnalyticsUtils"; import { handleAddNewReactions, handleViewPreviewReactions, handleViewReactions, handleRemoveAllReactions } from "../../../reactions/native/ReactionUtils"; import replyToMessage from "../../../replies/native/replyToMessage"; import { ComponentDispatch } from "../../../../utils/ComponentDispatchUtils"; import { openForwardModal } from "../../../forwarding/native/ForwardModalUtils"; import { ApplicationCommandType } from "../../../../flow/Server"; import { addOrUpdateSavedMessage, removeSavedMessage } from "../../../saved_messages/SavedMessageHelpers.native"; import PollsActionCreators from "../../../polls/PollsActionCreators"; import { HermesBuiltin } from "../../../../_hermes/prelude"; const handleEdit = function handleEdit(a0, a1, a2, a3, r5 = false) { L27: { if (a1.isForumPost() && (a1.id === SnowflakeUtils.castMessageIdAsChannelId(a0.id) && a1.parent_id != null)) { deletePendingReply(a1.id); openCreateForumPostModal({ guildId: a1.guild_id, parentChannelId: a1.parent_id, threadId: a1.id, messageId: a0.id, isEdit: true, analyticsLocations: [AnalyticsLocation.FORUM_CHANNEL, AnalyticsLocation.GUILD_CHANNEL], analyticsLocationObject: { page: AnalyticsPages.GUILD_CHANNEL, section: AnalyticsSections.FORUM_POST_HEADER, object: AnalyticsObjects.CONTEXT_MENU } }); } else if (r5 && (a3 === "message_swipe" && EditMessageStore.isEditing(a1.id, a0.id))) { const currentUser2 = UserStore.getCurrentUser(); AnalyticsUtils.track(AnalyticEvents.CHAT_CONTEXT_BAR_ACTION_CANCELED, { message_id: a0.id, channel_id: a1.id, guild_id: a1.guild_id, context_action: "edit", reason: "swipe_edit_undo", is_own_message: currentUser2 != null && currentUser2.id === a0.author.id }); MessageActionCreators.endEditMessage(a1.id); if (a2 == null) { break L27; } const current2 = a2.current; if (current2 == null) { break L27; } current2.dismissKeyboard(); } else { const pendingReply = PendingReplyStore.getPendingReply(a1.id); if (pendingReply != null) { const currentUser = UserStore.getCurrentUser(); AnalyticsUtils.track(AnalyticEvents.CHAT_CONTEXT_BAR_ACTION_CANCELED, { message_id: a0.id, channel_id: a1.id, guild_id: a1.guild_id, context_action: "reply", reason: a3 === "message_swipe" ? "swipe_edit" : a3 === "action_sheet" ? "action_sheet_edit" : a3 !== "cancel" ? void 0 : "pressed_cancel", is_own_message: currentUser != null && currentUser.id === pendingReply.message.author.id }); } deletePendingReply(a1.id); MessageActionCreators.startEditMessageRecord(a1.id, a0, a3); if (a2 != null) { const current = a2.current; if (current != null) { current.openSystemKeyboard(); } } } } }; export function getContextBarCancelReason(a0, a1) { if (a1 === "message_swipe") { return a0 === "reply" ? "swipe_edit" : "swipe_reply"; } if (a1 === "action_sheet") { return a0 === "reply" ? "action_sheet_edit" : "action_sheet_reply"; } if (a1 === "cancel") { return "pressed_cancel"; } } export { handleEdit }; export function handleCreateThread(a0, a1, r11 = "Message") { ThreadActionCreators.openThreadCreationForMobile(a0, a1?.id, r11); if (!(a1 == null || navigateToCreateThread(a0.guild_id, SnowflakeUtils.castMessageIdAsChannelId(a1.id)))) { transitionToGuild(a0.guild_id, SnowflakeUtils.castMessageIdAsChannelId(a1.id)); } } export function handleCopyMessageLink(a0, a1) { AnalyticsUtils.track(AnalyticEvents.MESSAGE_LINK_COPIED, { message_id: a1, channel: a0.id }); const channelPermalink = getChannelPermalink(a0.guild_id, a0.id, a1); if (channelPermalink != null) { copy(channelPermalink); presentLinkCopied(); } } export function handleCopyId(a0) { copy(a0); presentMessageIdCopied(); } export function longPressMessageOptionHandler({ label, message: message5, channel, chatInputRef, selectedMedia: selectedMedia3, actionSheetSource, analyticsLocations, onActionExecuted, onBack, disabled = false }) { const { guild_id, id } = channel; const id2 = message5.id; if (!disabled) { if (label !== intl.string(t.PHjkRE)) { ActionSheetActionCreators.hideActionSheet(); } L179: { if (intl.string(t["+78Pfm"]) !== label && intl.string(t.n5EBAJ) !== label) { if (intl.string(ReportToMod_messages["1D+vqy"]) === label) { if (!canReportMessageToMods(message5)) { break L179; } showReportToModMessageModal(message5); break L179; } if (intl.string(t.k5WiPf) === label) { if (message5.type !== MessageTypes.THREAD_STARTER_MESSAGE) { break L179; } if (message5.messageReference == null) { break L179; } const messageReference = message5.messageReference; const { message_id, guild_id: guild_id2, channel_id } = messageReference; if (guild_id2 == null) { break L179; } transitionToGuild(guild_id2, channel_id, message_id); break L179; } if (intl.string(t["+TSRGD"]) === label) { transitionToMessage(channel.id, message5.id); break L179; } if (intl.string(t.zBoHlf) === label) { copy(id2); presentMessageIdCopied(); break L179; } if (intl.string(t.P8tvKG) === label) { const user = UserStore.getUser(message5.author.id); if (user == null) { break L179; } if (chatInputRef != null) { const current7 = chatInputRef.current; if (current7 != null) { current7.insertText(`@${UserUtils.getUserTag(user, { decoration: "never" })}`, null, true); } } if (chatInputRef != null) { const current8 = chatInputRef.current; if (current8 != null) { current8.focus(); } } if (chatInputRef == null) { break L179; } const current9 = chatInputRef.current; if (current9 == null) { break L179; } current9.openSystemKeyboard(); break L179; } if (intl.string(t.cduTBL) === label) { showUserProfileActionSheet({ userId: message5.author.id, channelId: id, messageId: message5.id, sourceAnalyticsLocations: analyticsLocations }); break L179; } if (intl.string(t.fsBWmS) === label) { handleEdit(message5, channel, chatInputRef, "action_sheet"); break L179; } if (intl.string(t.MFGE51) === label) { const id8 = id; const id9 = id2; if (chatInputRef != null) { const current6 = chatInputRef.current; if (current6 != null) { current6.dismissKeyboard(); } } AlertActionCreators.show({ title: intl.string(t.aIz1oV), children: , cancelText: intl.string(t["ETE/oC"]), confirmText: intl.string(t["cY+Oob"]), onConfirm: () => MessageActionCreators.crosspostMessage(id8, id9) }); break L179; } if (intl.string(t.CvQ18w) === label) { const channel3 = channel; const message4 = message5; if (chatInputRef != null) { const current5 = chatInputRef.current; if (current5 != null) { current5.dismissKeyboard(); } } AlertActionCreators.show({ title: intl.string(t.CvQ18w), body: intl.string(t.WG5dyo), children: , cancelText: intl.string(t.gm1Vej), confirmText: intl.string(t.p89ACt), onConfirm: () => { ChannelPinActionCreators.pinMessage(channel3, message4.id); AccessibilityAnnouncer.announce(intl.string(t.sCfDDl)); } }); break L179; } if (intl.string(t["Bse+F/"]) === label) { const channel2 = channel; const message3 = message5; if (chatInputRef != null) { const current4 = chatInputRef.current; if (current4 != null) { current4.dismissKeyboard(); } } AlertActionCreators.show({ title: intl.string(t["Bse+F/"]), body: intl.string(t.NjEPp7), children: , cancelText: intl.string(t.gm1Vej), confirmText: intl.string(t.p89ACt), onConfirm: () => ChannelPinActionCreators.unpinMessage(channel2, message3.id) }); break L179; } if (intl.string(t["lE/PG3"]) === label) { MessageActionCreators.patchMessageGuildOfficial(id, id2, true); break L179; } if (intl.string(t["2km5Gf"]) === label) { MessageActionCreators.patchMessageGuildOfficial(id, id2, false); break L179; } if (intl.string(t.xwMqD7) === label) { if (message5.state === MessageStates.SENDING) { MessageQueue.cancelRequest(id2); } else if (message5.state === MessageStates.SEND_FAILED) { MessageActionCreators.deleteMessage(id, id2, true); } else { const id7 = id; const message2 = message5; if (chatInputRef != null) { const current3 = chatInputRef.current; if (current3 != null) { current3.dismissKeyboard(); } } AlertActionCreators.show({ title: intl.string(t.MWMcg7), body: intl.string(t.AMvpS4), children: , cancelText: intl.string(t.gm1Vej), confirmText: intl.string(t.p89ACt), onConfirm: () => { MessageActionCreators.deleteMessage(id7, message2.id, false); } }); } AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.MESSAGE_ACTION_SHEET_OPTION_PRESSED, { channel_id: id, guild_id, action_sheet_option: "delete", message_state: message5.state }); break L179; } if (intl.string(t["5911Lb"]) === label) { let r850 = UploadStore.getUploaderFileForMessageId(message5.id)?.items; if (r850 == null) { r850 = void 0; } retrySendMessage_native(channel, message5, r850, SendMessageOptionsStore.getOptions(message5.id)); AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.MESSAGE_ACTION_SHEET_OPTION_PRESSED, { channel_id: id, guild_id, action_sheet_option: "retry", message_state: message5.state }); break L179; } if (intl.string(t.JrGD7E) === label) { const contentMessage = message5.getContentMessage(); if (isMessageComponentsV2(contentMessage)) { const allTextDisplayContent = getAllTextDisplayContent(contentMessage.components); if (allTextDisplayContent != null) { copy(allTextDisplayContent); } } else { copy(contentMessage.content); } presentMessageCopied(); break L179; } if (intl.string(t.lfIHs4) === label) { handleAddNewReactions(channel, id2); break L179; } if (intl.string(t.gHp0C4) === label) { if (actionSheetSource === "Preview") { handleViewPreviewReactions(id2, id); break L179; } handleViewReactions({ messageId: id2, channelId: id, location: { object: AnalyticsObjects.MESSAGE_ACTION_SHEET } }); break L179; } if (intl.string(t.ZbtGBm) === label) { handleRemoveAllReactions(id, id2); break L179; } if (intl.string(t["g33r/P"]) === label) { ChannelActionCreators.openPrivateChannel({ recipientIds: message5.author.id }); break L179; } if (intl.string(t.Xrt5Po) === label) { AnalyticsUtils.track(AnalyticEvents.MESSAGE_LINK_COPIED, { message_id: id2, channel: channel.id }); const channelPermalink = getChannelPermalink(channel.guild_id, channel.id, id2); if (channelPermalink == null) { break L179; } copy(channelPermalink); presentLinkCopied(); break L179; } if (intl.string(t.RpE9k7) === label) { markUnread(id, id2); break L179; } if (intl.string(t["S/xNKV"]) === label) { const selectedMedia2 = selectedMedia3; const id6 = id; if (selectedMedia2?.mediaUrl == null) { break L179; } let c17296_2 = urlMatchesFileExtension(selectedMedia2.mediaUrl, GIF_RE_IOS); const r746 = URLUtils.toURLSafe(selectedMedia2.mediaUrl); (r746 != null && isAttachmentUrl(r746) ? maybeRefreshAttachmentUrl(selectedMedia2.mediaUrl) : Promise.resolve(selectedMedia2.mediaUrl)).then((result) => downloadMediaAssetWithContentType(result, c17296_2 ? MediaType.GIF : MediaType.IMAGE, selectedMedia2.contentType)).then(() => { if (c17296_2) { presentGifSaved(); } else { presentImageSaved(); } const CONTEXT_MENU_IMAGE_SAVED = AnalyticEvents.CONTEXT_MENU_IMAGE_SAVED; const isStaticChannelRoute2 = isStaticChannelRoute(id6); AnalyticsUtils.track(CONTEXT_MENU_IMAGE_SAVED, { ...{ channel_id: isStaticChannelRoute2 ? void 0 : id6, channel_static_route: isStaticChannelRoute2 ? id6 : void 0 } }); }, () => { AlertActionCreators.show({ title: intl.string(t.cV3alD), body: intl.string(t.r4Zjzv), isDismissable: true }); const CONTEXT_MENU_IMAGE_SAVE_FAILED = AnalyticEvents.CONTEXT_MENU_IMAGE_SAVE_FAILED; const isStaticChannelRoute2 = isStaticChannelRoute(id6); AnalyticsUtils.track(CONTEXT_MENU_IMAGE_SAVE_FAILED, { ...{ channel_id: isStaticChannelRoute2 ? void 0 : id6, channel_static_route: isStaticChannelRoute2 ? id6 : void 0 } }); }); break L179; } if (intl.string(t.JVuuz3) === label) { if (selectedMedia3?.mediaUrl == null) { break L179; } downloadMediaAssetWithContentType(selectedMedia3.mediaUrl, MediaType.VIDEO, selectedMedia3.contentType).then(() => { presentVideoSaved(); }, () => { AlertActionCreators.show({ title: intl.string(t.cV3alD), body: intl.string(t.r4Zjzv), isDismissable: true }); }); break L179; } if (intl.string(t.vbAEaA) === label) { const mediaUrl2 = selectedMedia3?.mediaUrl; if (mediaUrl2 == null) { break L179; } handleClick({ href: mediaUrl2 }); break L179; } if (intl.string(t["92CPQ+"]) !== label && intl.string(t["8xHmxo"]) !== label) { if (intl.string(t["5IEsGx"]) === label) { replyToMessage({ message: message5, channel, chatInputRef, actionSource: "action_sheet" }); if (actionSheetSource !== "Preview") { break L179; } transitionToMessage(channel.id, message5.id); setTimeout(() => ComponentDispatch.dispatch(ComponentActions.TEXTAREA_FOCUS, { channelId: channel.id }), 500); break L179; } if (intl.string(t.I3ltXO) === label) { openForwardModal({ message: message5, source: "long-press-sheet" }); break L179; } if (intl.string(t.rBIGBL) === label) { ThreadActionCreators.openThreadCreationForMobile(channel, message5?.id, "Message"); if (message5 == null || navigateToCreateThread(channel.guild_id, SnowflakeUtils.castMessageIdAsChannelId(message5.id))) { break L179; } transitionToGuild(channel.guild_id, SnowflakeUtils.castMessageIdAsChannelId(message5.id)); break L179; } if (intl.string(t["39d0Wj"]) === label) { transitionToGuild(channel.guild_id, SnowflakeUtils.castMessageIdAsChannelId(message5.id)); break L179; } if (intl.string(t.PHjkRE) === label) { ActionSheetActionCreators.hideActionSheet(); navigateToContextMenuCommands({ channel, commandType: ApplicationCommandType.MESSAGE, commandTargetId: message5.id }); break L179; } if (intl.string(t.tpxJto) === label) { addOrUpdateSavedMessage({ channelId: id, messageId: id2, displayToast: true }); break L179; } if (intl.string(t.SvXS1Z) === label) { removeSavedMessage({ channelId: id, messageId: id2, displayToast: true }); break L179; } if (intl.string(t.mJ3P0N) === label) { ActionSheetActionCreators.openLazy(import("../../../saved_messages/message_reminders/native/MessageReminderDurationActionSheet"), "MessageReminderDurationActionSheet", { createReminder: (a0) => addOrUpdateSavedMessage({ channelId: id, messageId: id2, dueAt: a0, displayToast: true }), channelId: message5.channel_id, messageId: message5.id, onBack }); break L179; } if (intl.string(t.vrbqs1) === label) { ActionSheetActionCreators.openLazy(import("../../../saved_messages/message_reminders/native/MessageReminderDurationActionSheet"), "MessageReminderDurationActionSheet", { createReminder: (a0) => addOrUpdateSavedMessage({ channelId: id, messageId: id2, dueAt: a0, displayToast: true }), removeReminder: () => removeSavedMessage({ channelId: id, messageId: id2, displayToast: true, isReminder: true }), channelId: message5.channel_id, messageId: message5.id, onBack }); break L179; } if (intl.string(t.ZH7P2h) === label) { if (selectedMedia3 == null) { break L179; } const embedId = selectedMedia3.sourceType === "embed" ? selectedMedia3.source.id : void 0; const attachmentId = selectedMedia3.sourceType === "attachment" ? selectedMedia3.source.id : void 0; if (!(embedId !== void 0 || attachmentId !== void 0 || messageHasObscurableMedia(message5))) { break L179; } ActionSheetActionCreators.openLazy(import("../../../explicit_media_redaction/native/false_positive_reporting/ExplicitMediaObscuredFalsePositiveActionSheet"), EXPLICIT_MEDIA_FALSE_POSITIVE_ACTION_SHEET_KEY, { channelId: message5.channel_id, messageId: message5.id, attachmentId, embedId }); break L179; } if (intl.string(t.grdwwt) === label) { PollsActionCreators.endPollEarly({ channelId: message5.channel_id, messageId: message5.id }); break L179; } if (intl.string(t.Rjezbz) === label) { ActionSheetActionCreators.openLazy(import("../../../applications/native/AppInteractionInfoActionSheet"), "AppInteractionInfoActionSheet", { message: message5, guildId: guild_id, onBack }); break L179; } if (intl.string(t["4sxKOb"]) !== label && intl.string(t.wUIMqa) !== label) { if (intl.string(t.kFwAsa) !== label) { break L179; } const id3 = id; const message = message5; const selectedMedia = selectedMedia3; if (selectedMedia?.sourceType !== "attachment") { break L179; } if (chatInputRef != null) { const current = chatInputRef.current; if (current != null) { current.dismissKeyboard(); } } AlertActionCreators.show({ title: intl.string(t.CbTIEo), body: intl.string(t.faHmO3), cancelText: intl.string(t["ETE/oC"]), confirmText: intl.string(t.kFwAsa), onConfirm: () => { const id10 = selectedMedia.source.id; MessageActionCreators.patchMessageAttachments(id3, message.id, message.attachments.filter((attachment) => attachment.id !== id10)); } }); break L179; } const id4 = id; const id5 = id2; if (chatInputRef != null) { const current2 = chatInputRef.current; if (current2 != null) { current2.dismissKeyboard(); } } AlertActionCreators.show({ title: intl.string(t.VL1KOk), body: intl.string(t["vXZ+Fo"]), cancelText: intl.string(t["ETE/oC"]), confirmText: intl.string(t.YEHppG), onConfirm: () => { MessageActionCreators.suppressEmbeds(id4, id5); } }); break L179; } const mediaUrl = selectedMedia3?.mediaUrl; let r682 = mediaUrl != null; if (r682) { copy(mediaUrl); presentLinkCopied(); r682 = true; } if (!r682) { break L179; } const CONTEXT_MENU_MEDIA_LINK_COPIED = AnalyticEvents.CONTEXT_MENU_MEDIA_LINK_COPIED; const r701 = { hostname: mediaUrl != null ? getHostname(mediaUrl) : void 0 }; const isStaticChannelRoute2 = isStaticChannelRoute(id); HermesBuiltin.copyDataProperties(r701, { channel_id: isStaticChannelRoute2 ? void 0 : id, channel_static_route: isStaticChannelRoute2 ? id : void 0 }); AnalyticsUtils.track(CONTEXT_MENU_MEDIA_LINK_COPIED, r701); } else if (canReportMessage(message5)) { showReportModalForMessage(message5, "mobile_message_action_sheet"); } } if (onActionExecuted != null) { onActionExecuted(label); } } }