This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,512 @@
// Metro module 9551 (f9552).
import { useEffect, useCallback } from "react";
import GuildAutomodMessageStore from "../../../guild_automod/GuildAutomodMessageStore";
import ReportToModStore from "../../../report_to_mod/ReportToModStore";
import SavedMessagesStore from "../../../saved_messages/SavedMessagesStore";
import { isMessageComponentsV2 } from "../../../../records/MessageRecord";
import AuthenticationStore from "../../../../stores/AuthenticationStore";
import GuildStore from "../../../../stores/GuildStore";
import PermissionStore from "../../../../stores/PermissionStore";
import { FileUploadErrorTypes } from "../../MessageConstants";
import { AnalyticEvents, AnalyticsPages, ChannelTypes, GuildFeatures, LOCAL_BOT_ID, MessageAttachmentFlags, MessageFlags, MessageStates, MessageTypes, MessageTypesSets, Permissions } from "../../../../Constants";
import useAnalyticsLocations, { AnalyticsLocationProvider } from "../../../app_analytics/useAnalyticsLocations";
import AnalyticsLocation from "../../../app_analytics/AnalyticsLocation";
import AppAnalyticsUtils from "../../../app_analytics/AppAnalyticsUtils";
import { showLongPressMessageActionSheet } from "./showLongPressMessageActionSheet";
import { useCanReplyToMessage } from "../../../replies/canReplyToMessage";
import { useCanForwardMessage } from "../../../forwarding/canForwardMessage";
import ForLaterExperiment from "../../../saved_messages/ForLaterExperiment";
import { useStateFromStoresArray, useStateFromStores } from "../../../../_bundle/Module589";
import hasForLaterPremiumType from "../../../saved_messages/hasForLaterPremiumType";
import { useIsNonModInLockedThread, useIsActiveChannelOrUnarchivableThread, computeCanStartPublicThread } from "../../../threads/ThreadHooks";
import useShouldHideMediaOptions from "../../../media_channel/useShouldHideMediaOptions";
import usePollMessageContextItemTypes, { PollMessageContextItemTypes } from "../../../polls/chat/usePollMessageContextItemTypes";
import { DeveloperMode } from "../../../user_settings/UserSettings";
import { useCanToggleGuildOfficialMessages } from "../../GuildOfficialMessageUtils";
import isMessagePinnable from "../../isMessagePinnable";
import { getAllTextDisplayContent } from "../../../interaction_components/InteractionComponentUtils";
import * as _Module1384 from "../../../../_bundle/Module1384";
import countContentTypes from "../../countContentTypes";
import { canRetryInteractionData } from "../../../interactions/InteractionUtils";
import { useIsReportToModEnabled } from "../../../report_to_mod/hooks/useReportToModHooks";
import { ActionSheetRow } from "../../../../design/components/Sheet/native/ActionSheetRow.native";
import { longPressMessageOptionHandler } from "./LongPressMessageActionSheetUtils";
import { ActionSheet } from "../../../../design/components/Sheet/native/ActionSheet.native";
import { isMetaQuest } from "../../../device/MetaQuestUtils.android";
import { shouldShowEmojiRow } from "../../../action_sheet/native/components/EmojiRowUtils";
import EmojiRow from "../../../action_sheet/native/components/EmojiRow";
import { intl, t } from "../../../../intl/index.native";
import { RetryIcon } from "../../../../design/components/Icon/native/redesign/generated/RetryIcon";
import { CopyIcon } from "../../../../design/components/Icon/native/redesign/generated/CopyIcon";
import { TrashIcon } from "../../../../design/components/Icon/native/redesign/generated/TrashIcon";
import { LinkIcon } from "../../../../design/components/Icon/native/redesign/generated/LinkIcon";
import { PencilIcon } from "../../../../design/components/Icon/native/redesign/generated/PencilIcon";
import { ArrowAngleLeftUpIcon } from "../../../../design/components/Icon/native/redesign/generated/ArrowAngleLeftUpIcon";
import ForwardingIcon from "../../../forwarding/native/ForwardingIcon";
import { ThreadIcon } from "../../../../design/components/Icon/native/redesign/generated/ThreadIcon";
import { ChatArrowRightIcon } from "../../../../design/components/Icon/native/redesign/generated/ChatArrowRightIcon";
import { ChatMarkUnreadIcon } from "../../../../design/components/Icon/native/redesign/generated/ChatMarkUnreadIcon";
import { ClockXIcon } from "../../../../design/components/Icon/native/redesign/generated/ClockXIcon";
import { ReactionIcon } from "../../../../design/components/Icon/native/redesign/generated/ReactionIcon";
import { AnnouncementsIcon } from "../../../../design/components/Icon/native/redesign/generated/AnnouncementsIcon";
import { PinIcon } from "../../../../design/components/Icon/native/redesign/generated/PinIcon";
import { StampIcon } from "../../../../design/components/Icon/native/redesign/generated/StampIcon";
import { StampXIcon } from "../../../../design/components/Icon/native/redesign/generated/StampXIcon";
import { NitroWheelIcon } from "../../../../design/components/Icon/native/redesign/generated/NitroWheelIcon";
import { BookmarkOutlineIcon } from "../../../../design/components/Icon/native/redesign/generated/BookmarkOutlineIcon";
import { BookmarkIcon } from "../../../../design/components/Icon/native/redesign/generated/BookmarkIcon";
import { ClockIcon } from "../../../../design/components/Icon/native/redesign/generated/ClockIcon";
import { RobotIcon } from "../../../../design/components/Icon/native/redesign/generated/RobotIcon";
import { ChatIcon } from "../../../../design/components/Icon/native/redesign/generated/ChatIcon";
import { AtIcon } from "../../../../design/components/Icon/native/redesign/generated/AtIcon";
import { DownloadIcon } from "../../../../design/components/Icon/native/redesign/generated/DownloadIcon";
import { IdIcon } from "../../../../design/components/Icon/native/redesign/generated/IdIcon";
import { XSmallBoldIcon } from "../../../../design/components/Icon/native/redesign/generated/XSmallBoldIcon";
import { FlagIcon } from "../../../../design/components/Icon/native/redesign/generated/FlagIcon";
import { ClydeIcon } from "../../../../design/components/Icon/native/redesign/generated/ClydeIcon";
import ReportToMod_messages from "../../../report_to_mod/ReportToMod.messages";
import { ImageWarningIcon } from "../../../../design/components/Icon/native/redesign/generated/ImageWarningIcon";
import { canReportMessageToMods } from "../../../report_to_mod/ReportToModUtils";
import { canReportUser, canReportMessage } from "../../../../utils/ReportUtils";
import canEditMessage from "../../canEditMessage";
import { isWebPlayerVideoUrl } from "../../MediaFormatTesters";
import { messageHasObscurableMedia } from "../../../explicit_media_redaction/ObscuredMediaUtils";
import { hasNonVoteReactions } from "../../../polls/PollsUtils";
import { canViewInteractionInfo } from "../../../applications/ApplicationInteractionInfoUtils";
export default function LongPressMessageActionSheet(a0) {
let callback, isActiveChannelOrUnarchivableThread, props, props2, props3, props4, props5, props6, props7, props8, props9, props10, props11, props12, props13, props14, props15, props16, props17, props18, props19, props20, props21, props22, props23, props24, props25, props26, c17286_37, c17286_38;
let c17286_0 = a0;
const analyticsLocations = useAnalyticsLocations(AnalyticsLocation.MESSAGE_LONG_PRESS_MENU).analyticsLocations;
let analyticsLocation = a0.analyticsLocation;
if (analyticsLocation === void 0) {
analyticsLocation = {};
}
let c17286_2 = analyticsLocation;
const { user, message, channel, chatInputRef, selectedMedia, actionSheetSource = void 0, canAddNewReactions = false } = a0;
useEffect(() => {
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.MESSAGE_ACTION_SHEET_OPENED, {
channel_id: channel.id,
guild_id: channel.guild_id,
location: {
page: channel.isPrivate() ? AnalyticsPages.DM_CHANNEL : AnalyticsPages.GUILD_CHANNEL,
...c17286_2
}
});
}, [analyticsLocation, channel]);
callback = useCallback(() => {
showLongPressMessageActionSheet(c17286_0);
}, [a0]);
const canReplyToMessage2 = useCanReplyToMessage(channel, message);
const canForwardMessage2 = useCanForwardMessage(message);
const guild = GuildStore.getGuild(channel.guild_id);
let enabled = ForLaterExperiment.useConfig({
location: "LongPressMessageActionSheet"
}).enabled;
const [r73, r74] = useStateFromStoresArray([SavedMessagesStore], () => [SavedMessagesStore.isMessageReminder(channel.id, message.id), SavedMessagesStore.isMessageBookmarked(channel.id, message.id)]);
const hasForLaterPremiumType2 = hasForLaterPremiumType();
const isNonModInLockedThread = useIsNonModInLockedThread(channel);
const shouldHideMediaOptions = useShouldHideMediaOptions(channel?.id);
const r154 = GuildAutomodMessageStore.getMessage(message.id) != null;
const interactionError = message.interactionError;
const EXPLICIT_CONTENT = FileUploadErrorTypes.EXPLICIT_CONTENT;
const pollMessageContextItemTypes = usePollMessageContextItemTypes(message);
isActiveChannelOrUnarchivableThread = useIsActiveChannelOrUnarchivableThread(channel);
const r69 = user == null ? void 0 : user.isNonUserBot();
const id = AuthenticationStore.getId();
const setting = DeveloperMode.getSetting();
const r49 = PermissionStore.can(Permissions.MANAGE_MESSAGES, channel);
const r178 = PermissionStore.can(Permissions.SEND_MESSAGES, channel);
const canToggleGuildOfficialMessages = useCanToggleGuildOfficialMessages(message, channel, "LongPressMessageActionSheet");
const id2 = message.author.id;
const hasFlag = message.hasFlag(MessageFlags.CROSSPOSTED);
const isMessagePinnable2 = isMessagePinnable(message, channel);
const r64 = (hasFlag ? !hasFlag : channel.type === ChannelTypes.GUILD_ANNOUNCEMENT) && (guild == null ? void 0 : guild.features.has(GuildFeatures.NEWS)) && r178 && (id2 === id || r49) && message.type === MessageTypes.DEFAULT && !message.isPoll();
const r77 = computeCanStartPublicThread(channel, message);
const contentMessage = message.getContentMessage();
const length = contentMessage.embeds.length;
const r214 = isMessageComponentsV2(contentMessage) ? getAllTextDisplayContent(contentMessage.components) : contentMessage.content;
const r65 = (r49 || message.canDeleteOwnMessage(id)) && length > 0 && message.author.id !== LOCAL_BOT_ID && !_Module1384.hasFlag(message.flags, MessageFlags.EPHEMERAL) && countContentTypes(message) >= 1;
const r239 = (r154 ? !r154 : !(interactionError === EXPLICIT_CONTENT)) && (message.interactionData == null || canRetryInteractionData(message.interactionData));
const r252 = message.attachments.filter((attachment) => attachment.flags == null || !_Module1384.hasFlag(attachment.flags, MessageAttachmentFlags.IS_THUMBNAIL));
const r54 = message.author.id === id && (r252.length > 1 || message.content !== "");
const stateFromStores = useStateFromStores([ReportToModStore], () => ReportToModStore.hasReportedMessage(message.channel_id, message.id));
const id3 = guild?.id;
const getProps = function getProps({ arrow, IconComponent, label, onActionExecuted, variant, disabled }) {
return {
arrow,
icon: <ActionSheetRow.Icon IconComponent={IconComponent} />,
label,
onPress: () => {
(0, longPressMessageOptionHandler)({
actionSheetSource,
analyticsLocations,
channel,
chatInputRef,
label,
message,
onBack: callback,
onActionExecuted,
selectedMedia,
disabled
});
},
variant,
disabled
};
};
const render = function render(a0) {
return <AnalyticsLocationProvider value={analyticsLocations}>
<ActionSheet showGradient startExpanded={isMetaQuest()} header={shouldShowEmojiRow(canAddNewReactions, message, isActiveChannelOrUnarchivableThread) && <EmojiRow message={message} channel={channel} />}>
{a0 == null ? void 0 : a0.map((a0, a1) => <ActionSheetRow.Group key={a1} hasIcons>
{a0.map((item, index) => {
const { icon, arrow } = item;
return <ActionSheetRow key={index} icon={icon} arrow={arrow} label={item.label} onPress={item.onPress} variant={item.variant} disabled={item.disabled} />;
})}
</ActionSheetRow.Group>)}
</ActionSheet>
</AnalyticsLocationProvider>;
};
const isReportToModEnabled = useIsReportToModEnabled(id3);
if (message.state === MessageStates.SEND_FAILED) {
const r1103 = [];
if (r239) {
r1103.push(getProps({
label: intl.string(t["5911Lb"]),
IconComponent: RetryIcon
}));
}
if (r214 != null && r214.length > 0) {
r1103.push(getProps({
label: intl.string(t.JrGD7E),
IconComponent: CopyIcon
}));
}
r1103.push(getProps({
label: intl.string(t.xwMqD7),
IconComponent: TrashIcon,
variant: "danger"
}));
return render([r1103]);
}
if (message.state === MessageStates.SENDING) {
const r1059 = r214 != null && r214.length > 0;
const r1062 = [];
if (r1059) {
r1062.push(getProps({
label: intl.string(t.JrGD7E),
IconComponent: CopyIcon
}));
}
r1062.push(getProps({
label: intl.string(t.xwMqD7),
IconComponent: TrashIcon,
variant: "danger"
}));
return render([r1062]);
}
if (message.type === MessageTypes.THREAD_STARTER_MESSAGE) {
return render([[getProps({
label: intl.string(t.k5WiPf),
IconComponent: LinkIcon
})]]);
}
props = getProps({
label: intl.string(t.fsBWmS),
IconComponent: PencilIcon
});
props2 = getProps({
label: intl.string(t["5IEsGx"]),
IconComponent: ArrowAngleLeftUpIcon
});
props3 = getProps({
label: intl.string(t.I3ltXO),
IconComponent: ForwardingIcon
});
props4 = getProps({
label: intl.string(t.rBIGBL),
IconComponent: ThreadIcon
});
const r44 = getProps({
label: intl.string(t["39d0Wj"]),
IconComponent: ThreadIcon
});
const r45 = getProps({
label: intl.string(t["+TSRGD"]),
IconComponent: ChatArrowRightIcon
});
const r43 = getProps({
label: intl.string(t.JrGD7E),
IconComponent: CopyIcon
});
props5 = getProps({
label: intl.string(t.RpE9k7),
IconComponent: ChatMarkUnreadIcon
});
const r41 = getProps({
label: intl.string(t.grdwwt),
IconComponent: ClockXIcon
});
const r40 = getProps({
label: intl.string(t.gHp0C4),
IconComponent: ReactionIcon
});
props6 = getProps({
label: intl.string(t.MFGE51),
IconComponent: AnnouncementsIcon
});
props7 = getProps({
label: intl.string(t.CvQ18w),
IconComponent: PinIcon
});
props8 = getProps({
label: intl.string(t["Bse+F/"]),
IconComponent: PinIcon
});
props9 = getProps({
label: intl.string(t["lE/PG3"]),
IconComponent: StampIcon
});
props10 = getProps({
label: intl.string(t["2km5Gf"]),
IconComponent: StampXIcon
});
props11 = getProps({
label: intl.string(t.tpxJto),
IconComponent: NitroWheelIcon
});
props12 = getProps({
label: intl.string(t.tpxJto),
IconComponent: BookmarkOutlineIcon
});
props13 = getProps({
label: intl.string(t.SvXS1Z),
IconComponent: BookmarkIcon
});
props14 = getProps({
label: intl.string(t.mJ3P0N),
IconComponent: ClockIcon,
arrow: true
});
props15 = getProps({
label: intl.string(t.vrbqs1),
IconComponent: ClockIcon,
arrow: true
});
props16 = getProps({
label: intl.string(t.PHjkRE),
IconComponent: RobotIcon,
arrow: true
});
props17 = getProps({
label: intl.string(t["g33r/P"]),
IconComponent: ChatIcon
});
props18 = getProps({
label: intl.string(t.P8tvKG),
IconComponent: AtIcon
});
const r26 = getProps({
label: intl.string(t["S/xNKV"]),
IconComponent: DownloadIcon
});
const r25 = getProps({
label: intl.string(t.JVuuz3),
IconComponent: DownloadIcon
});
const r24 = getProps({
label: intl.string(t.vbAEaA),
IconComponent: DownloadIcon
});
let r621 = false;
try {
const r630 = selectedMedia?.mediaUrl != null ? new URL(selectedMedia.mediaUrl) : null;
r621 = selectedMedia?.mediaType === "image" && r630 != null && r630.hostname === "cdn.discordapp.com" && /\.(png|jpe?g|webp|avif|bmp|svg)(\?|$)/i.test(r630.pathname);
} catch ($e) {}
const r23 = getProps({
label: intl.string(r621 ? t["8xHmxo"] : t["92CPQ+"]),
IconComponent: LinkIcon
});
props19 = getProps({
label: intl.string(t.Xrt5Po),
IconComponent: LinkIcon
});
const r689 = getProps({
label: intl.string(t.Rjezbz),
IconComponent: ClockIcon,
arrow: true
});
const r703 = getProps({
label: intl.string(t.zBoHlf),
IconComponent: IdIcon
});
props20 = getProps({
label: length > 1 ? intl.string(t.wUIMqa) : intl.string(t["4sxKOb"]),
IconComponent: XSmallBoldIcon,
variant: "danger"
});
props21 = getProps({
label: intl.string(t.ZbtGBm),
IconComponent: TrashIcon,
variant: "danger"
});
props22 = getProps({
label: intl.string(t.kFwAsa),
IconComponent: TrashIcon,
variant: "danger"
});
props23 = getProps({
label: intl.string(t["+78Pfm"]),
IconComponent: FlagIcon,
variant: "danger"
});
props24 = getProps({
label: intl.string(t.n5EBAJ),
variant: "danger",
IconComponent: ClydeIcon
});
props25 = getProps({
label: intl.string(ReportToMod_messages["1D+vqy"]),
IconComponent: FlagIcon,
disabled: stateFromStores
});
const r811 = getProps({
label: intl.string(t.ZH7P2h),
IconComponent: ImageWarningIcon
});
props26 = getProps({
label: intl.string(t.xwMqD7),
IconComponent: TrashIcon,
variant: "danger"
});
c17286_37 = (() => {
const r33 = actionSheetSource === "Preview" || _Module1384.hasFlag(message.flags, MessageFlags.EPHEMERAL);
const r41 = [];
if (r33) {
r41.push(props4, props5, props12, props13, props11, props14, props15, props20, props26, props, props18, props17, props16, props21);
}
let r43 = isActiveChannelOrUnarchivableThread;
if (isActiveChannelOrUnarchivableThread) {
r43 = !_Module1384.hasFlag(message.flags, MessageFlags.EPHEMERAL);
}
if (!r43) {
r41.push(props, props2, props20, props22, props26, props6, props7, props8, props9, props10, props5, props18, props16, props21);
}
if (_Module1384.hasFlag(message.flags, MessageFlags.EPHEMERAL)) {
r41.push(props3, props2, props19, props23, props24, props25);
}
return new Set(r41);
})();
const r827 = [];
if (actionSheetSource === "Preview") {
r827.unshift(r45);
}
if (r77) {
r827.unshift(props4);
} else if (message.hasFlag(MessageFlags.HAS_THREAD)) {
r827.unshift(r44);
}
r827.unshift(props19);
if (setting) {
r827.unshift(r703);
}
if (isReportToModEnabled && canReportMessageToMods(message)) {
r827.unshift(props24);
r827.unshift(props25);
} else if (user != null && canReportUser(user) && canReportMessage(message)) {
r827.unshift(props23);
}
r827.unshift(props5);
if (enabled) {
enabled = r74 || r73 || channel.isPrivate() || PermissionStore.can(Permissions.READ_MESSAGE_HISTORY, channel);
}
L110: {
if (enabled) {
if (!hasForLaterPremiumType2 && !r74 && !r73) {
r827.unshift(props11);
break L110;
}
r827.unshift(r74 ? props13 : props12);
r827.unshift(r73 ? props15 : props14);
}
}
if (r65) {
r827.unshift(props20);
}
if (!((r49 ? !r49 : !message.canDeleteOwnMessage(id)) || MessageTypesSets.UNDELETABLE.has(message.type))) {
r827.unshift(props26);
}
if (canEditMessage(message, id) && !isNonModInLockedThread) {
r827.unshift(props);
}
if (r64) {
r827.unshift(props6);
}
const r901 = channel.type === ChannelTypes.GROUP_DM;
if (!(channel.isPrivate() && !r901 || r69 === true)) {
if (PermissionStore.can(Permissions.SEND_MESSAGES, channel) || r901) {
r827.unshift(props18);
}
if (id !== user?.id) {
r827.unshift(props17);
}
}
if (isMessagePinnable2) {
r827.unshift(message.pinned ? props8 : props7);
}
if (canToggleGuildOfficialMessages) {
r827.unshift(_Module1384.hasFlag(message.flags, MessageFlags.IS_GUILD_OFFICIAL) ? props10 : props9);
}
if (r214 != null && r214.length > 0) {
r827.unshift(r43);
}
if (canReplyToMessage2) {
r827.unshift(props2);
}
if (canForwardMessage2) {
r827.unshift(props3);
}
if (!(selectedMedia == null || shouldHideMediaOptions)) {
L165: {
r827.unshift(r23);
if (selectedMedia.mediaType === "image") {
r827.unshift(r26);
} else {
if (selectedMedia.mediaType === "video" && !isWebPlayerVideoUrl(selectedMedia.mediaUrl)) {
r827.unshift(r25);
break L165;
}
if (!(selectedMedia.mediaType !== "audio" && selectedMedia.mediaType !== "file")) {
r827.unshift(r24);
}
}
}
if (messageHasObscurableMedia(message)) {
r827.unshift(r811);
}
if (selectedMedia.sourceType === "attachment" && r54) {
r827.unshift(props22);
}
}
let r977 = message.reactions.length > 0;
if (r977) {
const isPoll = message.isPoll();
r977 = isPoll ? hasNonVoteReactions(message) : !isPoll;
}
if (r977) {
r827.unshift(r40);
if (r49) {
r827.unshift(props21);
}
}
for (const item of pollMessageContextItemTypes) {
if (item === PollMessageContextItemTypes.END_EARLY) {
r827.unshift(r41);
}
}
r827.unshift(props16);
if (canViewInteractionInfo(message)) {
r827.unshift(r689);
}
c17286_38 = new Set(r827.filter((item) => !c17286_37.has(item)));
return render([[props, props2, props3, props4], [r45, r44, r43, props5, r41, r40, props6, props7, props8, props9, props10, props11, props12, props13, props14, props15, props16, props17, props18, r26, r25, r24, r23, props19, r689, r703], [props20, props21, props22, props23, props24, props25, r811, props26]].map((a0) => a0.filter((item) => c17286_38.has(item))).filter((item) => item.length > 0));
};
@@ -0,0 +1,671 @@
// 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: <PublishModal channelId={id} />,
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: <LongPressMessageChatItemPreview message={message4} />,
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: <LongPressMessageChatItemPreview message={message3} />,
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: <LongPressMessageChatItemPreview message={message2} />,
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);
}
}
}
@@ -0,0 +1,14 @@
// Metro module 9881 (f9882).
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../_bundle/Module712";
import RowGenerator from "../renderer/RowGenerator";
import ChatItem from "../../../../components_native/chat/ChatItem";
const useStyles = createStyles({
chatItem: {
maxHeight: 2 * Module712.space.PX_80
}
});
const rowGenerator = new RowGenerator();
export default function LongPressMessageChatItemPreview(props) {
return <ChatItem rowGenerator={rowGenerator} message={props.message} maxHeight={useStyles().chatItem.maxHeight} backgroundColor={Module712.colors.MOBILE_ALERT_BACKGROUND_DEFAULT} />;
};
@@ -0,0 +1,5 @@
// Metro module 9550 (f9551).
import ActionSheetActionCreators from "../../../action_sheet/native/ActionSheetActionCreators";
export function showLongPressMessageActionSheet(a0) {
ActionSheetActionCreators.openLazy(import("./LongPressMessageActionSheet"), "MessageLongPressActionSheet", a0);
}