764 lines
25 KiB
TypeScript
764 lines
25 KiB
TypeScript
// Metro module 9309 (f9310).
|
|
import { updateShouldShowJumpToPresentButton } from "../../chat_input/native/useChatBottomManagerUIStore";
|
|
import ReferencedMessageStore from "../../replies/ReferencedMessageStore";
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import GuildMemberStore from "../../../stores/GuildMemberStore";
|
|
import GuildVerificationStore from "../../../stores/GuildVerificationStore";
|
|
import MessageStore from "../../../stores/MessageStore";
|
|
import NetworkStore from "../../../stores/NetworkStore";
|
|
import PermissionStore from "../../../stores/PermissionStore";
|
|
import ReadStateStore from "../../../stores/ReadStateStore";
|
|
import UserStore from "../../../stores/UserStore";
|
|
import { RowType, Changeset } from "./renderer/RowGeneratorConstants";
|
|
import { MessageTypes, MessageEmbedTypes, AnalyticEvents, Permissions, MAX_MESSAGES_PER_CHANNEL } from "../../../Constants";
|
|
import { isVideoFile, isAudioFile, isImageFile, isVideoContentType } from "../MediaFormatTesters";
|
|
import { flattenComponents } from "../../interaction_components/InteractionComponentUtils";
|
|
import { ComponentType } from "../../../flow/Server";
|
|
import { ObscuredMediaTypes } from "../../explicit_media_redaction/ExplicitMediaRedactionModels";
|
|
import { ReactionLocations, addReaction, removeReaction } from "../../reactions/ReactionActionCreators";
|
|
import { shouldShowMembershipVerificationGate } from "../../guild_member_verification/hooks/useShowMemberVerificationGate";
|
|
import * as _CommunicationDisabledUtils from "../../guild_communication_disabled/CommunicationDisabledUtils";
|
|
import ToastActionCreators from "../../toast/native/ToastActionCreators";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import Module9311 from "../../../_bundle/Module9311";
|
|
import { handleOutOfSuperReactions, handleAddNewReactions } from "../../reactions/native/ReactionUtils";
|
|
import { isPremium } from "../../../utils/PremiumTypeUtils";
|
|
import { triggerHapticFeedback } from "../../haptics/HapticUtils.native";
|
|
import HapticFeedbackTypes from "../../haptics/HapticFeedbackTypes";
|
|
import { openMemberVerificationModal } from "../../guild_member_verification/MemberVerificationModalActionCreators";
|
|
import ThreadActionCreators from "../../threads/ThreadActionCreators";
|
|
import { trackForumPostLinkCopied } from "../../forums/tracking/Tracking";
|
|
import { trackWithMetadata } from "../../app_analytics/AppAnalyticsUtils";
|
|
import { copy } from "../../../utils/ClipboardUtils.native";
|
|
import { getChannelPermalink, getChannelLinkToCopy } from "../../../utils/ChannelUtils";
|
|
import SnowflakeUtils from "../../../utils/SnowflakeUtils";
|
|
import { presentLinkCopied } from "../../toast/native/ToastUtils";
|
|
import { findMessageRowIndex } from "../../chat/native/computeScrollData";
|
|
import TTITracker from "../../tti_analytics/TTITracker";
|
|
import Module12 from "../../../_bundle/Module12";
|
|
import { isIOS } from "../../../utils/PlatformUtils";
|
|
import { KeyboardTypes } from "../../keyboard/native/KeyboardTypes";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
import NativeChatUtils, { ChatScrollPosition } from "../../chat/native/NativeChatUtils";
|
|
import MessageActionCreators from "../../../actions/MessageActionCreators";
|
|
import { QuestsVisibleMessagesChangedSource } from "../../quests/QuestTypes";
|
|
import { JumpType } from "../../../flow/Client";
|
|
import { questsVisibleMobileMessagesChanged } from "../../quests/QuestActionCreators";
|
|
import { handleAnnouncementMessageViewTracking, handleOfficialMessageViewTracking, handleRichPresenceInviteEmbedViewTracking, handleVoiceInviteEmbedViewTracking } from "./MessageImpressionAnalyticsHelpers";
|
|
function $mk82284() {
|
|
return (a0) => a0.id;
|
|
}
|
|
function $mk82287($env) {
|
|
return () => {
|
|
const r9 = $env;
|
|
const r3 = r9[2];
|
|
const scrollToMessageId3 = r9[0];
|
|
const r7 = r3(scrollToMessageId3);
|
|
if (r7 != null) {
|
|
const r11 = r9[1];
|
|
if (r11.current != null) {
|
|
const r12 = r9[4];
|
|
let r13 = false;
|
|
if (r12) {
|
|
const r5 = r9[3];
|
|
const r15 = $env.$parent;
|
|
r5({
|
|
scrollToMessageId: scrollToMessageId3,
|
|
jumpTargetId: scrollToMessageId3,
|
|
jumpType: r9[5],
|
|
focusTargetId: scrollToMessageId3,
|
|
overrideScrollJumpType: (0, r15[0])(r15[2][45]).JumpType.INSTANT,
|
|
isRescrolling: true
|
|
});
|
|
r13 = true;
|
|
}
|
|
if (!r13) {
|
|
const r23 = $env.$parent;
|
|
(0, r23[1])(r23[2][42]).scrollTo(r11.current, r7, {
|
|
animated: r9[5] === (0, r23[0])(r23[2][45]).JumpType.ANIMATED
|
|
});
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
function $mk115464($env) {
|
|
return () => {
|
|
const r3 = $env;
|
|
return (0, r3[1])(!r3[0]);
|
|
};
|
|
}
|
|
let getMessage, parseVoiceStateChannelIdSummary;
|
|
let env6129 = {};
|
|
export function getVisibleMessages({ firstVisibleMessageRowIndex, lastVisibleMessageRowIndex, firstVisibleMessagePercentVisible, lastVisibleMessagePercentVisible, chatManager, channelId }) {
|
|
let percentVisible;
|
|
if (firstVisibleMessageRowIndex != null && lastVisibleMessageRowIndex != null && !(firstVisibleMessageRowIndex < 0) && !(lastVisibleMessageRowIndex < 0) && chatManager._rows != null && chatManager._messages != null) {
|
|
const r21 = [];
|
|
let r6 = firstVisibleMessageRowIndex;
|
|
while (r6 >= lastVisibleMessageRowIndex) {
|
|
const r15 = chatManager._rows[r6];
|
|
const r23 = r6;
|
|
if (r15 != null && r15.type === RowType.MESSAGE) {
|
|
if (r15.message?.id != null) {
|
|
if (r23 === firstVisibleMessageRowIndex) {
|
|
percentVisible = firstVisibleMessagePercentVisible;
|
|
if (percentVisible == null) {
|
|
percentVisible = r23 === lastVisibleMessageRowIndex && lastVisibleMessagePercentVisible != null ? lastVisibleMessagePercentVisible : 1;
|
|
}
|
|
} else {
|
|
percentVisible = r23 === lastVisibleMessageRowIndex && lastVisibleMessagePercentVisible != null ? lastVisibleMessagePercentVisible : 1;
|
|
}
|
|
const message = MessageStore.getMessage(channelId, r15.message.id);
|
|
if (message != null) {
|
|
r21.push({
|
|
message,
|
|
percentVisible,
|
|
state: message.state
|
|
});
|
|
}
|
|
}
|
|
}
|
|
r6 = r23 - 1;
|
|
}
|
|
return r21;
|
|
}
|
|
return [];
|
|
}
|
|
getMessage = function getMessage(a0, c17128_0) {
|
|
return Module12.find(a0.toArray(), ({ id, nonce }) => id === c17128_0 || nonce === c17128_0);
|
|
};
|
|
parseVoiceStateChannelIdSummary = function parseVoiceStateChannelIdSummary(a0) {
|
|
const map = new Map();
|
|
if (a0 != null && a0 !== "") {
|
|
for (const item of a0.split("|")) {
|
|
const [r40, r42] = item.split(":");
|
|
if (r40 != null) {
|
|
let r44 = r42;
|
|
if (r44 == null) {
|
|
r44 = "";
|
|
}
|
|
map.set(r40, r44);
|
|
}
|
|
}
|
|
return map;
|
|
}
|
|
return map;
|
|
};
|
|
export function getLongPressSelectedMedia(a0, a1, a2, a3, a4) {
|
|
const type = a0.type;
|
|
const THREAD_STARTER_MESSAGE = MessageTypes.THREAD_STARTER_MESSAGE;
|
|
let r3 = a0;
|
|
if (type === THREAD_STARTER_MESSAGE) {
|
|
const messageReference = a0.messageReference;
|
|
r3 = a0;
|
|
if (messageReference != null) {
|
|
const message = ReferencedMessageStore.getMessageByReference(a0.messageReference).message;
|
|
r3 = message ?? a0;
|
|
}
|
|
}
|
|
if (a2 === "attachment") {
|
|
let source3 = r3.attachments[a1];
|
|
if (source3 == null) {
|
|
const contentMessage = r3.getContentMessage();
|
|
source3 = contentMessage == null ? void 0 : contentMessage.attachments[a1];
|
|
}
|
|
const r99 = source3 == null;
|
|
let r100 = null;
|
|
if (!r99) {
|
|
const mediaType = isVideoFile(source3.filename) ? "video" : isAudioFile(source3.filename) ? "audio" : isImageFile(source3.filename) ? "image" : "file";
|
|
let content_type = source3.content_type;
|
|
if (content_type == null) {
|
|
content_type = void 0;
|
|
}
|
|
r100 = {
|
|
sourceType: "attachment",
|
|
source: source3,
|
|
mediaType,
|
|
mediaUrl: source3.url,
|
|
contentType: content_type
|
|
};
|
|
}
|
|
return r100;
|
|
}
|
|
if (a2 === "embed") {
|
|
const source2 = r3.embeds[a1];
|
|
if (source2 == null) {
|
|
return null;
|
|
}
|
|
if (source2.type === MessageEmbedTypes.IMAGE && source2.url != null) {
|
|
return {
|
|
sourceType: "embed",
|
|
source: source2,
|
|
mediaType: "image",
|
|
mediaUrl: source2.url,
|
|
contentType: void 0
|
|
};
|
|
}
|
|
if (source2.type === MessageEmbedTypes.GIFV) {
|
|
if (source2.video?.url != null) {
|
|
return {
|
|
sourceType: "embed",
|
|
source: source2,
|
|
mediaType: "video",
|
|
mediaUrl: source2.video.proxyURL != null && source2.video.proxyURL !== "" ? source2.video.proxyURL : source2.video.url,
|
|
contentType: source2.video.contentType
|
|
};
|
|
}
|
|
}
|
|
if (source2.type === MessageEmbedTypes.RICH) {
|
|
if (source2.image?.url != null) {
|
|
return {
|
|
sourceType: "embed",
|
|
source: source2,
|
|
mediaType: "image",
|
|
mediaUrl: source2.image.url,
|
|
contentType: source2.image.contentType
|
|
};
|
|
}
|
|
if (source2.video?.url != null) {
|
|
return {
|
|
sourceType: "embed",
|
|
source: source2,
|
|
mediaType: "video",
|
|
mediaUrl: source2.video.url,
|
|
contentType: source2.video.contentType
|
|
};
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
if (a2 === "component") {
|
|
if (a3 == null) {
|
|
return null;
|
|
}
|
|
const source = flattenComponents(r3.components).get(a3);
|
|
if (source == null) {
|
|
return null;
|
|
}
|
|
if (source.type === ComponentType.MEDIA_GALLERY) {
|
|
if (a4 == null) {
|
|
return null;
|
|
}
|
|
const r38 = source.items[a4];
|
|
if (r38 == null) {
|
|
return null;
|
|
}
|
|
const media = r38.media;
|
|
return {
|
|
sourceType: "component",
|
|
source,
|
|
mediaType: isVideoContentType(media.contentType) ? "video" : "image",
|
|
mediaUrl: media.url
|
|
};
|
|
}
|
|
return null;
|
|
}
|
|
return null;
|
|
}
|
|
export function toObscuredMedia(a0) {
|
|
return a0.sourceType === "attachment" ? {
|
|
type: ObscuredMediaTypes.Attachment,
|
|
media: a0.source
|
|
} : a0.sourceType === "embed" ? {
|
|
type: ObscuredMediaTypes.Embed,
|
|
media: a0.source
|
|
} : null;
|
|
}
|
|
export function handleAddOrRemoveReaction(a0, a1, a2, burst = false, location2 = ReactionLocations.MESSAGE) {
|
|
const guildId = a1.getGuildId();
|
|
const currentUser = UserStore.getCurrentUser();
|
|
const id = currentUser?.id;
|
|
const r8 = guildId != null && GuildVerificationStore.canChatInGuild(guildId);
|
|
const r33 = guildId != null && shouldShowMembershipVerificationGate(guildId);
|
|
const r14 = guildId != null ? id != null ? GuildMemberStore.getMember(guildId, id) : null : null;
|
|
L38: {
|
|
const isMemberCommunicationDisabled = _CommunicationDisabledUtils.isMemberCommunicationDisabled(r14);
|
|
if (a1.isArchivedLockedThread()) {
|
|
ToastActionCreators.open({
|
|
key: "ARCHIVED_POST_REACTIONS_DISABLED_TOAST",
|
|
content: a1.isForumPost() ? intl.string(t.EJQrFq) : intl.string(t.X2L3Oa),
|
|
icon: Module9311
|
|
});
|
|
} else {
|
|
if (a2 != null) {
|
|
if (burst && !a2.me_burst === true && !isPremium(currentUser)) {
|
|
return handleOutOfSuperReactions();
|
|
}
|
|
L33: {
|
|
if (a2.me !== true) {
|
|
if (burst && a2.me_burst === true) {
|
|
break L33;
|
|
}
|
|
L30: {
|
|
if (!r33) {
|
|
if (!a1.isPrivate() && !r8) {
|
|
break L30;
|
|
}
|
|
if (!isMemberCommunicationDisabled) {
|
|
addReaction(a1.id, a0, a2.emoji, location2, {
|
|
burst
|
|
});
|
|
if (!burst) {
|
|
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_LIGHT);
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
}
|
|
if (!r33) {
|
|
break L38;
|
|
}
|
|
const guildId2 = a1.getGuildId();
|
|
if (guildId2 == null) {
|
|
break L38;
|
|
}
|
|
return openMemberVerificationModal(guildId2);
|
|
}
|
|
}
|
|
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_LIGHT);
|
|
removeReaction({
|
|
channelId: a1.id,
|
|
messageId: a0,
|
|
emoji: a2.emoji,
|
|
location: location2,
|
|
options: {
|
|
burst
|
|
}
|
|
});
|
|
return void 0;
|
|
}
|
|
handleAddNewReactions(a1, a0, location2, {
|
|
burst
|
|
});
|
|
}
|
|
}
|
|
}
|
|
export function handleToggleFollowForumPost(a0, a1) {
|
|
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_LIGHT);
|
|
if (a1) {
|
|
ThreadActionCreators.leaveThread(a0, "iOS Forum Toolbar");
|
|
} else {
|
|
ThreadActionCreators.joinThread(a0, "iOS Forum Toolbar");
|
|
}
|
|
}
|
|
export function handleCopyLinkForumPost(a0, a1, a2) {
|
|
const channel2 = ChannelStore.getChannel(a1);
|
|
const channel = ChannelStore.getChannel(channel2?.parent_id);
|
|
let r16 = channel == null ? void 0 : channel.isMediaChannel();
|
|
if (r16 == null) {
|
|
r16 = false;
|
|
}
|
|
trackForumPostLinkCopied({
|
|
postId: a1,
|
|
location: a2
|
|
});
|
|
if (r16) {
|
|
trackWithMetadata(AnalyticEvents.MEDIA_POST_SHARE_PROMPT_CLICKED, {
|
|
media_post_id: a1
|
|
});
|
|
}
|
|
triggerHapticFeedback(HapticFeedbackTypes.IMPACT_LIGHT);
|
|
if (channel2 == null) {
|
|
copy(getChannelPermalink(a0, a1, r16 === true ? SnowflakeUtils.castChannelIdAsMessageId(a1) : void 0));
|
|
} else {
|
|
copy(getChannelLinkToCopy(channel2, channel));
|
|
}
|
|
presentLinkCopied();
|
|
}
|
|
export function findMessageIndex(a0, a1) {
|
|
if (a1 != null) {
|
|
return findMessageRowIndex(a0, a1);
|
|
}
|
|
}
|
|
export function shouldJumpToOriginalPost(a0, a1, a2, a3) {
|
|
return a0.isForumPost() && SnowflakeUtils.castChannelIdAsMessageId(a1) === a2.jumpTargetId && !a3;
|
|
}
|
|
export function startOrCancelChannelLatestMessagesLoad(a0) {
|
|
if (a0.jumpTargetId == null && (a0.oldestUnreadMessageId == null && !a0.shouldJumpToOriginalPost)) {
|
|
a0.tracker.start({
|
|
channelId: a0.channelId
|
|
});
|
|
} else {
|
|
a0.tracker.cancel();
|
|
}
|
|
}
|
|
export function recordTimings(a0, a1) {
|
|
TTITracker.recordMessageRender(a0, a1.map($mk82284()), a1.hasFetched || a1.ready && !a1.cached, a1.hasMoreAfter);
|
|
}
|
|
export function findMessageIndexInRows(a0, a1) {
|
|
if (a0 != null) {
|
|
return findMessageRowIndex(a1, a0);
|
|
}
|
|
}
|
|
export { getMessage };
|
|
export function isLoadingAtTop(a0, a1) {
|
|
if (!a1) {
|
|
return false;
|
|
}
|
|
for (const item of a0) {
|
|
if (item.changeType !== Changeset.INSERT) {
|
|
continue;
|
|
}
|
|
return item.index <= 1;
|
|
}
|
|
return false;
|
|
}
|
|
export function handleTapTableView(a0, a1) {
|
|
if (isIOS() && a1 !== KeyboardTypes.SYSTEM) {
|
|
const current = a0.current;
|
|
if (current != null) {
|
|
current.closeCustomKeyboard();
|
|
}
|
|
}
|
|
}
|
|
export function handleMediaPlayFinishedAnalytics(a0) {
|
|
AnalyticsUtils.track(AnalyticEvents.MEDIA_PLAY_FINISHED, {
|
|
play_time_sec: a0.playWallTimeMs / 1000,
|
|
play_wall_time_ms: a0.playWallTimeMs,
|
|
first_play_waiting_ms: Math.min(a0.firstPlayWaitingMs, 600000),
|
|
stall_count: a0.stallCount,
|
|
stall_ms: a0.stallMs,
|
|
seek_count: a0.seekCount,
|
|
seek_waiting_ms: null,
|
|
media_source: a0.mediaSource,
|
|
mime_type: a0.mimeType != null ? a0.mimeType !== "" ? a0.mimeType : null : null,
|
|
file_size: null,
|
|
file_duration_sec: a0.fileDurationSec,
|
|
connection_type: NetworkStore.getType(),
|
|
effective_connection_speed: NetworkStore.getEffectiveConnectionSpeed(),
|
|
service_provider: NetworkStore.getServiceProvider()
|
|
});
|
|
}
|
|
export function scrollToBottom(a0, a1, a2, r5 = true) {
|
|
a2({
|
|
eventTimestamp: Date.now(),
|
|
isAtBottom: true
|
|
});
|
|
const current = a0.current;
|
|
if (r5) {
|
|
r5 = !a1;
|
|
}
|
|
NativeChatUtils.scrollToBottom(current, r5);
|
|
}
|
|
export function scrollToTop({ current }, a1, r5 = true) {
|
|
if (r5) {
|
|
r5 = !a1;
|
|
}
|
|
NativeChatUtils.scrollToTop(current, r5);
|
|
}
|
|
export function scrollToRelativeOffset({ current }, a1, a2, r6 = true) {
|
|
if (r6) {
|
|
r6 = !a1;
|
|
}
|
|
NativeChatUtils.scrollToRelativeOffset(current, a2, r6);
|
|
}
|
|
export function scrollToTopMessage(a0, a1) {
|
|
const previousRows = a1.getPreviousRows();
|
|
if (previousRows.length > 0) {
|
|
NativeChatUtils.scrollTo(a0.current, previousRows.length - 1);
|
|
}
|
|
}
|
|
export function canAddNewReactions(a0, a1) {
|
|
return (a1 ? PermissionStore.can(Permissions.ADD_REACTIONS, a0) : a1) || a0.isPrivate();
|
|
}
|
|
export function loadMoreBefore(a0, a1, a2) {
|
|
a2(true);
|
|
if (a1.hasMoreBefore && !a1.loadingMore) {
|
|
MessageActionCreators.fetchMessages({
|
|
channelId: a0,
|
|
before: a1.first()?.id,
|
|
limit: MAX_MESSAGES_PER_CHANNEL
|
|
});
|
|
}
|
|
}
|
|
export function loadMoreAfter(a0, a1, a2) {
|
|
a2(true);
|
|
if (a1.hasMoreAfter && !a1.loadingMore) {
|
|
MessageActionCreators.fetchMessages({
|
|
channelId: a0,
|
|
after: a1.last()?.id,
|
|
limit: MAX_MESSAGES_PER_CHANNEL
|
|
});
|
|
}
|
|
}
|
|
export function clearRows(a0, a1, a2, a3, a4) {
|
|
a4({
|
|
animated: false,
|
|
hasHandledScroll: false,
|
|
isNearBottom: false,
|
|
isAtBottom: false,
|
|
isNearTop: false,
|
|
decelerating: false,
|
|
dragging: false,
|
|
hasMoreMessagesAfterForLastUpdate: false,
|
|
pendingUpdatesQueue: [],
|
|
_loaded: false,
|
|
animatingStickerMessageId: null
|
|
});
|
|
a1.clear();
|
|
(0, updateShouldShowJumpToPresentButton)(a2, a3, false);
|
|
NativeChatUtils.clearRows(a0.current);
|
|
}
|
|
export function handleFirstLayout(a0, a1, a2, a3, a4) {
|
|
a0({
|
|
firstVisibleMessageRowIndex: a1,
|
|
lastVisibleMessageRowIndex: a2,
|
|
firstVisibleMessagePercentVisible: a3,
|
|
lastVisibleMessagePercentVisible: a4,
|
|
source: QuestsVisibleMessagesChangedSource.FIRST_LAYOUT
|
|
});
|
|
}
|
|
export function handleMessageVisibilityChanged(a0, a1, a2, a3, a4) {
|
|
a0({
|
|
firstVisibleMessageRowIndex: a1,
|
|
lastVisibleMessageRowIndex: a2,
|
|
firstVisibleMessagePercentVisible: a3,
|
|
lastVisibleMessagePercentVisible: a4,
|
|
source: QuestsVisibleMessagesChangedSource.VISIBILITY_CHANGED
|
|
});
|
|
}
|
|
export function handleLongPressSticker(a0, a1, a2) {
|
|
const set = new Set([a0]);
|
|
if (a1 != null) {
|
|
set.add(a1);
|
|
}
|
|
const r14 = a1 !== a0 ? a0 : null;
|
|
a2({
|
|
forceRender: true,
|
|
updateMessageIds: set
|
|
});
|
|
return r14;
|
|
}
|
|
export async function handleTapNavBar(c26422_0) {
|
|
let c26422_1;
|
|
L19: {
|
|
L18: {
|
|
L14: {
|
|
let env30085;
|
|
const r13 = env30085 = {};
|
|
c26422_1 = r13;
|
|
env30085[0] = void 0;
|
|
env30085[1] = void 0;
|
|
const { channel, useReducedMotion } = c26422_0;
|
|
env30085[0] = useReducedMotion;
|
|
const { isNearTop, messages: messages2, findMessageIndex: findMessageIndex2 } = c26422_0;
|
|
env30085[1] = c26422_0.scrollToTop;
|
|
const chatRef2 = c26422_0.chatRef;
|
|
if (!channel.isForumPost()) {
|
|
break L19;
|
|
}
|
|
if (isNearTop) {
|
|
break L19;
|
|
}
|
|
if (getMessage(messages2, SnowflakeUtils.castChannelIdAsMessageId(channel.id)) == null) {
|
|
await MessageActionCreators.fetchMessages({
|
|
channelId: channel.id,
|
|
jump: {
|
|
messageId: channel.id,
|
|
flash: false
|
|
},
|
|
limit: MAX_MESSAGES_PER_CHANNEL
|
|
});
|
|
setTimeout($mk115464(c26422_1), 50);
|
|
break L18;
|
|
}
|
|
const r60 = findMessageIndex2(SnowflakeUtils.castChannelIdAsMessageId(channel.id));
|
|
if (r60 == null) {
|
|
break L14;
|
|
}
|
|
NativeChatUtils.scrollTo(chatRef2.current, r60, {
|
|
animated: !useReducedMotion
|
|
});
|
|
setTimeout(() => (0, env30085[1])(!env30085[0]), 10 * r60);
|
|
break L19;
|
|
}
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
export function jumpToPresent(a0, a1, a2) {
|
|
const jumpReturnTargetId = a0.jumpReturnTargetId;
|
|
if (jumpReturnTargetId == null) {
|
|
if (!a0.loadingMore) {
|
|
if (a0.hasMoreAfter) {
|
|
MessageActionCreators.fetchMessages({
|
|
channelId: a1.id,
|
|
limit: MAX_MESSAGES_PER_CHANNEL,
|
|
jump: {
|
|
present: true
|
|
}
|
|
});
|
|
} else {
|
|
a2();
|
|
}
|
|
}
|
|
} else {
|
|
MessageActionCreators.jumpToMessage({
|
|
channelId: a1.id,
|
|
messageId: jumpReturnTargetId,
|
|
flash: true
|
|
});
|
|
}
|
|
}
|
|
export function scrollToNewMessages({ channel }) {
|
|
let messageId = ReadStateStore.ackMessageId(channel.id);
|
|
if (messageId == null) {
|
|
messageId = channel.id;
|
|
}
|
|
MessageActionCreators.jumpToMessage({
|
|
channelId: channel.id,
|
|
messageId,
|
|
offset: 1,
|
|
context: "Mark As Read"
|
|
});
|
|
}
|
|
export function syncMessageDisplay({ messages, isMessagesReady, oldestUnreadMessageId, channelId, updateRows, scrollToMessageId }) {
|
|
if (isMessagesReady) {
|
|
updateRows({
|
|
scrollToMessageId: messages.jumpTargetId,
|
|
jumpTargetId: messages.jumpTargetId,
|
|
jumpType: JumpType.INSTANT,
|
|
focusTargetId: messages.focusTargetId
|
|
});
|
|
if (messages.jumpTargetId != null) {
|
|
scrollToMessageId({
|
|
scrollToMessageId: messages.jumpTargetId,
|
|
jumpTargetId: messages.jumpTargetId,
|
|
jumpType: JumpType.INSTANT
|
|
});
|
|
} else if (oldestUnreadMessageId != null) {
|
|
setTimeout(() => scrollToMessageId({
|
|
scrollToMessageId: oldestUnreadMessageId,
|
|
jumpTargetId: messages.jumpTargetId,
|
|
jumpType: JumpType.INSTANT
|
|
}), 50);
|
|
}
|
|
} else {
|
|
updateRows({});
|
|
}
|
|
TTITracker.recordMessageRender(channelId, messages.map($mk82284()), messages.hasFetched || messages.ready && !messages.cached, messages.hasMoreAfter);
|
|
}
|
|
export function getChatRef(a0) {
|
|
return a0;
|
|
}
|
|
export function maybeRescrollToMessageId(a0, a1) {
|
|
let env17129;
|
|
const r3 = env17129 = {
|
|
$parent: env6129
|
|
};
|
|
env17129[0] = a0;
|
|
env17129[1] = a1.chatRef;
|
|
env17129[2] = a1.findMessageIndex;
|
|
env17129[3] = a1.updateRows;
|
|
const updateRowsEnabled = a1.updateRowsEnabled;
|
|
env17129[4] = updateRowsEnabled !== void 0 && updateRowsEnabled;
|
|
let jumpType = a1.jumpType;
|
|
if (jumpType === void 0) {
|
|
jumpType = JumpType.INSTANT;
|
|
}
|
|
env17129[5] = jumpType;
|
|
if (a0 != null) {
|
|
setTimeout($mk82287(r3), 50);
|
|
}
|
|
}
|
|
export function scrollToMessageIdWithRescroll(a0) {
|
|
let animated, c17131_4;
|
|
const { scrollToMessageId: scrollToMessageId2, jumpTargetId = null, jumpType = JumpType.ANIMATED, scrollPosition = ChatScrollPosition.TOP, minimizeScrolling = false, isRescrolling = false } = a0;
|
|
let useReducedMotion = a0.useReducedMotion;
|
|
const { chatRef, findMessageIndex: findMessageIndex2, updateRows } = a0;
|
|
if (!useReducedMotion) {
|
|
useReducedMotion = jumpType === JumpType.INSTANT;
|
|
}
|
|
L25: {
|
|
animated = !useReducedMotion;
|
|
if (isIOS() && !isRescrolling) {
|
|
let r46 = useReducedMotion ? JumpType.INSTANT : JumpType.ANIMATED;
|
|
let env17132;
|
|
const r47 = env17132 = {
|
|
$parent: env6129
|
|
};
|
|
env17132[0] = scrollToMessageId2;
|
|
env17132[1] = chatRef;
|
|
env17132[2] = findMessageIndex2;
|
|
env17132[3] = updateRows;
|
|
env17132[4] = true;
|
|
if (r46 === void 0) {
|
|
r46 = JumpType.INSTANT;
|
|
}
|
|
env17132[5] = r46;
|
|
if (scrollToMessageId2 == null) {
|
|
break L25;
|
|
}
|
|
setTimeout($mk82287(r47), 50);
|
|
} else {
|
|
const r55 = findMessageIndex2(scrollToMessageId2);
|
|
c17131_4 = r55;
|
|
if (r55 != null) {
|
|
if (minimizeScrolling) {
|
|
setTimeout(() => {
|
|
NativeChatUtils.scrollIntoView(chatRef.current, c17131_4, {
|
|
animated,
|
|
highlight: jumpTargetId === scrollToMessageId2
|
|
});
|
|
}, 5);
|
|
} else {
|
|
NativeChatUtils.scrollTo(chatRef.current, r55, {
|
|
animated,
|
|
highlight: jumpTargetId === scrollToMessageId2,
|
|
position: scrollPosition
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
export function handleVisibleMessagesChange({ firstVisibleMessageRowIndex, firstVisibleMessagePercentVisible, lastVisibleMessageRowIndex, lastVisibleMessagePercentVisible, source, chatManager, shouldTrackAnnouncementMessageViews, shouldTrackOfficialMessageViews, shouldTrackRichPresenceInviteEmbedViews, shouldTrackVoiceInviteEmbedViews, guildId, channelId, channel }) {
|
|
if (firstVisibleMessageRowIndex != null && lastVisibleMessageRowIndex != null && firstVisibleMessagePercentVisible != null && lastVisibleMessagePercentVisible != null) {
|
|
const visibleMessages = getVisibleMessages({
|
|
firstVisibleMessageRowIndex,
|
|
lastVisibleMessageRowIndex,
|
|
firstVisibleMessagePercentVisible,
|
|
lastVisibleMessagePercentVisible,
|
|
chatManager,
|
|
channelId
|
|
});
|
|
if (!(visibleMessages.length <= 0)) {
|
|
questsVisibleMobileMessagesChanged({
|
|
visibleMessages,
|
|
source
|
|
});
|
|
handleAnnouncementMessageViewTracking(visibleMessages, shouldTrackAnnouncementMessageViews, guildId, channel);
|
|
handleOfficialMessageViewTracking(visibleMessages, shouldTrackOfficialMessageViews, guildId, channel);
|
|
handleRichPresenceInviteEmbedViewTracking(visibleMessages, shouldTrackRichPresenceInviteEmbedViews, guildId, channel);
|
|
handleVoiceInviteEmbedViewTracking(visibleMessages, shouldTrackVoiceInviteEmbedViews, guildId, channel);
|
|
}
|
|
}
|
|
}
|
|
export function getVoiceStateChannelSummaryFromVoiceStates(a0) {
|
|
return Object.entries(a0).filter((item) => {
|
|
const [, r13] = item;
|
|
return r13.discoverable !== false;
|
|
}).map((item) => {
|
|
const [r7, r24] = item;
|
|
let channelId = r24.channelId;
|
|
if (channelId == null) {
|
|
channelId = "";
|
|
}
|
|
return `${r7}:${channelId}`;
|
|
}).sort().join("|");
|
|
}
|
|
export function getVoiceChannelIdChangedAuthorIds(a0, a1) {
|
|
const r4 = parseVoiceStateChannelIdSummary(a0);
|
|
const r3 = parseVoiceStateChannelIdSummary(a1);
|
|
const set = new Set();
|
|
const r29 = Set;
|
|
const r31 = [...r4.keys(), ...r3.keys()];
|
|
for (const item of new r29(r31)) {
|
|
if (r4.get(item) !== r3.get(item)) {
|
|
set.add(item);
|
|
}
|
|
}
|
|
return set;
|
|
}
|