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,32 @@
// Metro module 10901 (f10902).
import { useState } from "react";
import ChannelLatestMessageLoadingStatsManager from "../ChannelLatestMessageLoadingStatsManager";
import { startOrCancelChannelLatestMessagesLoad } from "../MessagesUtils";
import useMountEffect from "../../../../_bundle/useMountEffect";
export default function useChannelLoading({ channelId, jumpTargetId, oldestUnreadMessageId, shouldJumpToOriginalPost }) {
const [state] = useState(() => new ChannelLatestMessageLoadingStatsManager("Messages"));
useMountEffect(() => {
startOrCancelChannelLatestMessagesLoad({
jumpTargetId,
oldestUnreadMessageId,
shouldJumpToOriginalPost: shouldJumpToOriginalPost(false),
channelId,
tracker: state
});
return () => {
state.cancel();
};
});
return {
channelLatestMessageLoadingStatsManager: state,
startOrCancelLatestMessagesLoad: function startOrCancelLatestMessagesLoad(a0) {
startOrCancelChannelLatestMessagesLoad({
jumpTargetId,
oldestUnreadMessageId,
shouldJumpToOriginalPost: shouldJumpToOriginalPost(a0),
channelId,
tracker: state
});
}
};
};
@@ -0,0 +1,321 @@
// Metro module 11144 (f11145).
import TTITracker from "../../../tti_analytics/TTITracker";
import { JumpType } from "../../../../flow/Client";
import NativeChatUtils, { ChatScrollPosition } from "../../../chat/native/NativeChatUtils";
import { isIOS } from "../../../../utils/PlatformUtils";
import computeScrollData from "../../../chat/native/computeScrollData";
function $mk107736($env) {
return () => {
const r4 = $env;
const r0 = $env.$parent;
const chatManager = r0[0];
const messages = r0[5];
chatManager.setup(messages);
r0[1].setOptions({
inlineAttachmentMedia: r0[11],
inlineEmbedMedia: r0[12],
renderEmbeds: r0[13],
renderReactions: r0[14],
animateEmoji: r0[15],
animatingStickerMessageId: r0[2].current,
constrainedWidth: r0[26],
gifAutoPlay: r0[16],
timestampHourCycle: r0[17],
renderCommunicationDisabled: r0[19],
ignoreEmbedDescriptionCache: r4[2],
enableSwipeActions: r0[21],
shouldObscureSpoiler: r0[23],
shouldDisableInteractiveComponents: r0[24]
});
const r36 = $env.$parent.$parent;
for (const item of (0, r36[1])(r36[2][1])({
channel: r0[4],
messages,
uploads: r0[7],
oldestUnreadMessageId: r0[9],
replyingMessageId: r0[10],
currentUserId: r0[18],
canAddNewReactions: (0, r0[3])(),
selectedSummary: r0[20],
chatManager,
roleStyle: r0[8],
forceRender: r4[0],
updateMessageIds: r4[1],
isResourceChannel: r0[22],
unloadableContentEntryMessageIds: r0[25]
})) {
r0[0].createRow(r0[1].generate(item));
}
return r0[0].createChangeset();
};
}
function $mk107737($env) {
return () => {
const r9 = $env;
const r4 = $env.$parent;
const r3 = r4[38];
const scrollToMessageId3 = r9[0];
const r7 = r3(scrollToMessageId3);
if (r7 != null) {
const r11 = r4[27];
if (r11.current != null) {
const r12 = r9[1];
let r13 = false;
if (r12) {
const r14 = r4[42];
const r16 = $env.$parent.$parent;
r14({
scrollToMessageId: scrollToMessageId3,
jumpTargetId: scrollToMessageId3,
jumpType: r9[2],
focusTargetId: scrollToMessageId3,
overrideScrollJumpType: (0, r16[0])(r16[2][2]).JumpType.INSTANT,
isRescrolling: true,
hasJumpedToOriginalPost: r9[3]
});
r13 = true;
}
if (!r13) {
const r24 = $env.$parent.$parent;
(0, r24[1])(r24[2][3]).scrollTo(r11.current, r7, {
animated: r9[2] === (0, r24[0])(r24[2][2]).JumpType.ANIMATED
});
}
}
}
};
}
let env7531 = {};
export default function useRowManager(a0) {
let env18559 = {
$parent: env7531
};
env18559[0] = a0.chatManager;
env18559[1] = a0.rowGenerator;
env18559[2] = a0.animatingStickerMessageIdRef;
env18559[3] = a0.canAddNewReactions;
env18559[4] = a0.channel;
env18559[5] = a0.messages;
env18559[6] = a0.isMessagesReady;
env18559[7] = a0.uploads;
env18559[8] = a0.roleStyle;
env18559[9] = a0.oldestUnreadMessageId;
env18559[10] = a0.replyingMessageId;
env18559[11] = a0.inlineAttachmentMedia;
env18559[12] = a0.inlineEmbedMedia;
env18559[13] = a0.renderEmbeds;
env18559[14] = a0.renderReactions;
env18559[15] = a0.animateEmoji;
env18559[16] = a0.gifAutoPlay;
env18559[17] = a0.timestampHourCycle;
env18559[18] = a0.currentUserId;
env18559[19] = a0.renderCommunicationDisabled;
env18559[20] = a0.selectedSummary;
env18559[21] = a0.enableSwipeActions;
env18559[22] = a0.isResourceChannel;
env18559[23] = a0.shouldObscureSpoiler;
env18559[24] = a0.shouldDisableInteractiveComponents;
env18559[25] = a0.unloadableContentEntryMessageIds;
env18559[26] = a0.containerWidth;
env18559[27] = a0.chatRef;
env18559[28] = a0.loadedRef;
env18559[29] = a0.animatedRef;
env18559[30] = a0.hasMoreMessagesAfterForLastUpdateRef;
env18559[31] = a0.updateNativeRows;
env18559[32] = a0.isLoadingAtTop;
env18559[33] = a0.channelLatestMessageLoadingStatsManager;
env18559[34] = a0.channelId;
env18559[35] = a0.isMessagesCached;
env18559[36] = a0.chatUpdatesQueue;
env18559[37] = a0.shouldJumpToOriginalPost;
env18559[38] = a0.findMessageIndex;
env18559[39] = a0.scrollToTopMessage;
env18559[40] = a0.useReducedMotion;
const scrollToMessageId = function scrollToMessageId(a0) {
let animated, c26950_3;
const { scrollToMessageId: scrollToMessageId2, jumpTargetId = null } = a0;
let c26950_1 = jumpTargetId;
const { jumpType = JumpType.ANIMATED, scrollPosition = ChatScrollPosition.TOP, minimizeScrolling = false, isRescrolling = false } = a0;
let hasJumpedToOriginalPost = a0.hasJumpedToOriginalPost;
if (hasJumpedToOriginalPost === void 0) {
hasJumpedToOriginalPost = false;
}
animated = void 0;
c26950_3 = void 0;
const r13 = env18559[40] || jumpType === JumpType.INSTANT;
L29: {
animated = !r13;
if (isIOS() && !isRescrolling) {
let r46 = r13 ? JumpType.INSTANT : JumpType.ANIMATED;
let env26951;
const r47 = env26951 = {
$parent: env18559
};
env26951[0] = scrollToMessageId2;
env26951[1] = true;
if (r46 === void 0) {
r46 = JumpType.INSTANT;
}
env26951[2] = r46;
if (hasJumpedToOriginalPost === void 0) {
hasJumpedToOriginalPost = false;
}
env26951[3] = hasJumpedToOriginalPost;
if (scrollToMessageId2 == null) {
break L29;
}
setTimeout($mk107737(r47), 50);
} else {
const r59 = (0, env18559[38])(scrollToMessageId2);
c26950_3 = r59;
if (r59 != null) {
if (minimizeScrolling) {
setTimeout(() => {
NativeChatUtils.scrollIntoView(env18559[27].current, c26950_3, {
animated,
highlight: c26950_1 === scrollToMessageId2
});
}, 5);
} else {
NativeChatUtils.scrollTo(env18559[27].current, r59, {
animated,
highlight: jumpTargetId === scrollToMessageId2,
position: scrollPosition
});
}
}
}
}
};
env18559[41] = scrollToMessageId;
const updateRows = function updateRows(r4 = {}) {
const { forceRender = false, forceReload, updateMessageIds = new Set(), scrollToMessageId: scrollToMessageId3 = null, jumpTargetId = null, jumpType = JumpType.ANIMATED, focusTargetId = null, ignoreEmbedDescriptionCache = false, messagesNewlyLoaded = false, shouldInitialScroll = false, minimizeScrolling = false, isRescrolling = false } = r4;
let overrideScrollJumpType = r4.overrideScrollJumpType;
const { isAnimated = true, hasJumpedToOriginalPost = false } = r4;
const r38 = env18559[27];
if (r38.current != null) {
let env26952;
const r40 = env26952 = {
$parent: env18559
};
env26952[0] = forceRender;
env26952[1] = updateMessageIds;
env26952[2] = ignoreEmbedDescriptionCache;
const rows = env18559[4] != null ? env18559[5] != null ? env18559[6] ? TTITracker.firstRowGenerator.measure($mk107736(r40)) : null : null : null;
const r53 = env18559[28];
const current = r53.current;
const r55 = env18559[20];
const scrollPosition = r55 != null ? r55.startId === scrollToMessageId3 ? ChatScrollPosition.MIDDLE : void 0 : void 0;
L57: {
if (rows != null && rows.length > 0) {
const r103 = {
rows: env18559[0].getPreviousRows(),
scrollToMessageId: scrollToMessageId3,
jumpTargetId,
jumpType: null,
shouldInitialScroll: null,
animated: null,
scrollPosition: null,
focusTargetId: null
};
if (overrideScrollJumpType == null) {
overrideScrollJumpType = env18559[5].jumpType;
}
r103.jumpType = overrideScrollJumpType;
const current2 = r53.current;
r103.shouldInitialScroll = current2 ? shouldInitialScroll : !current2;
r103.animated = env18559[29].current;
r103.scrollPosition = scrollPosition;
r103.focusTargetId = focusTargetId;
const scrollData = computeScrollData(r103);
r53.current = true;
(0, env18559[31])({
rows,
hasMoreMessagesAfter: env18559[5].hasMoreAfter,
isLoadingAtTop: (0, env18559[32])(rows, env18559[30].current),
scrollData,
HACK_iOSForceAnimations: messagesNewlyLoaded,
forceReload,
isAnimated
});
if (current) {
break L57;
}
env18559[33].finish({
channelId: env18559[34],
areMessagesCached: env18559[35]
});
} else {
if (r53.current) {
const r66 = env18559[36];
if (r66.hasUpdates()) {
r66.tryFlush();
break L57;
}
}
if (!r53.current && (rows != null && rows.length === 0)) {
NativeChatUtils.fadeIn(r38.current);
} else if (scrollToMessageId3 != null && !(0, env18559[37])(hasJumpedToOriginalPost)) {
(0, env18559[41])({
scrollToMessageId: scrollToMessageId3,
jumpTargetId,
jumpType,
scrollPosition,
minimizeScrolling,
isRescrolling,
hasJumpedToOriginalPost
});
} else if (focusTargetId != null) {
const r84 = (0, env18559[38])(focusTargetId);
if (r84 != null) {
NativeChatUtils.focus(r38.current, r84);
}
}
}
}
if (r53.current && r53.current !== current && env18559[22]) {
setTimeout(() => (0, env18559[39])(), 100);
}
}
};
env18559[42] = updateRows;
return {
createRows: function createRows(a0) {
let env26948;
const r3 = env26948 = {
$parent: env18559
};
env26948[0] = a0.forceRender;
env26948[1] = a0.updateMessageIds;
env26948[2] = a0.ignoreEmbedDescriptionCache;
return env18559[4] != null ? env18559[5] != null ? env18559[6] ? TTITracker.firstRowGenerator.measure($mk107736(r3)) : null : null : null;
},
updateRows,
scrollToMessageId,
maybeRescrollToMessageId: function maybeRescrollToMessageId(a0) {
let env26949;
const r3 = env26949 = {
$parent: env18559
};
env26949[0] = a0;
let r5 = arguments[1];
if (r5 === void 0) {
r5 = false;
}
env26949[1] = r5;
let r8 = arguments[2];
if (r8 === void 0) {
r8 = JumpType.INSTANT;
}
env26949[2] = r8;
let r13 = arguments[3];
if (r13 === void 0) {
r13 = false;
}
env26949[3] = r13;
if (a0 != null) {
setTimeout($mk107737(r3), 50);
}
}
};
};
@@ -0,0 +1,199 @@
// Metro module 10903 (f10904).
import { useRef } from "react";
import { updateIsAtBottom, updateShouldShowJumpToPresentButton } from "../../../chat_input/native/useChatBottomManagerUIStore";
import Logger from "../../../debug/Logger";
import { getIsScreenReaderEnabled } from "../../../a11y/native/useIsScreenReaderEnabled.native";
import DimensionActionCreators from "../../../../actions/DimensionActionCreators";
import { batchUpdates } from "../../../../_bundle/Module705";
import NativeChatUtils from "../../../chat/native/NativeChatUtils";
import { getChangesetIdForChat } from "../../../chat/native/ChatChangesetUpdateTracker";
import { QuestsVisibleMessagesChangedSource } from "../../../quests/QuestTypes";
let c7341_6 = new Logger("useScrollHandlers");
export default function useScrollHandlers({ chatRef, chatManager, chatUpdatesQueue, pendingUpdatesQueueRef, animatedRef, fetchMoreBefore, fetchMoreAfter, handleVisibleMessagesChange, applyNativeRowsUpdate, messages, channel, channelId, screenIndex, onScroll, useReducedMotion, isStaff, visibleMessagesWindowHandler }) {
let ref, ref2, ref3, ref4, ref5, ref6, ref7, handleScroll2;
ref = void 0;
ref2 = void 0;
ref3 = void 0;
ref4 = void 0;
ref5 = void 0;
ref6 = void 0;
ref7 = void 0;
const handleScrollCallbacks2 = function handleScrollCallbacks(a0) {
const { eventTimestamp, isAtBottom: isAtBottom2, isNearBottom = false, isNearTop = false } = a0;
let dragging = a0.dragging;
if (dragging === void 0) {
dragging = false;
}
const { decelerating = false, isFirstMessageVisible = false } = a0;
L38: {
if (channel != null) {
if (messages.length === 0 && messages.loadingMore) {
break L38;
}
const isScreenReaderEnabled = getIsScreenReaderEnabled();
const loadingMore = messages.loadingMore;
let r32 = !loadingMore;
if (!loadingMore) {
if (!dragging) {
dragging = decelerating;
}
if (!dragging) {
dragging = isScreenReaderEnabled;
}
r32 = dragging;
}
if (r32) {
r32 = pendingUpdatesQueueRef.current.length === 0;
}
if (!ref5.current && (isNearTop && (messages.hasMoreBefore && r32))) {
animatedRef.current = true;
fetchMoreBefore();
} else if (!ref4.current && (isNearBottom && (messages.hasMoreAfter && r32))) {
animatedRef.current = true;
fetchMoreAfter();
} else if (!(ref3.current === isAtBottom2 && ref2.current)) {
DimensionActionCreators.updateChannelDimensions(channel.id, eventTimestamp, isAtBottom2 ? 1 : 0, 1, 0);
ref2.current = true;
}
onScroll({
isFirstMessageVisible
});
chatUpdatesQueue.tryFlush();
return true;
}
}
return false;
};
handleScroll2 = function handleScroll(a0) {
const { eventTimestamp, isAtBottom, isNearBottom = false, isNearTop = false, dragging = false, decelerating = false, shouldShowJumpToPresent = false } = a0;
let c26846_1 = shouldShowJumpToPresent;
let isFirstMessageVisible = a0.isFirstMessageVisible;
if (isFirstMessageVisible === void 0) {
isFirstMessageVisible = false;
}
if (handleScrollCallbacks2({
eventTimestamp,
isAtBottom,
isNearBottom,
isNearTop,
dragging,
decelerating,
shouldShowJumpToPresent,
isFirstMessageVisible
})) {
ref3.current = isAtBottom;
ref4.current = isNearBottom;
ref5.current = isNearTop;
ref7.current = dragging;
ref6.current = decelerating;
batchUpdates(() => {
updateShouldShowJumpToPresentButton(channelId, screenIndex, c26846_1 || messages.hasMoreAfter);
updateIsAtBottom(screenIndex, isAtBottom);
});
}
};
ref = useRef(void 0);
ref2 = useRef(false);
ref3 = useRef(false);
ref4 = useRef(false);
ref5 = useRef(false);
ref6 = useRef(false);
ref7 = useRef(false);
return {
hasHandledScrollRef: ref2,
isAtBottomRef: ref3,
isNearBottomRef: ref4,
isNearTopRef: ref5,
deceleratingRef: ref6,
draggingRef: ref7,
firstIgnoredScrollEventTimestampRef: ref,
loadMoreBefore: function loadMoreBefore() {
animatedRef.current = true;
fetchMoreBefore();
},
loadMoreAfter: function loadMoreAfter() {
animatedRef.current = true;
fetchMoreAfter();
},
scrollToTop: function scrollToTop(r5 = true) {
const current = chatRef.current;
if (r5) {
r5 = !useReducedMotion;
}
NativeChatUtils.scrollToTop(current, r5);
},
scrollToRelativeOffset: function scrollToRelativeOffset(a0, r6 = true) {
const current = chatRef.current;
if (r6) {
r6 = !useReducedMotion;
}
NativeChatUtils.scrollToRelativeOffset(current, a0, r6);
},
scrollToTopMessage: function scrollToTopMessage() {
const previousRows = chatManager.getPreviousRows();
if (previousRows.length > 0) {
NativeChatUtils.scrollTo(chatRef.current, previousRows.length - 1);
}
},
updateNativeRows: function updateNativeRows(a0) {
L7: {
if (chatUpdatesQueue.isBlocking) {
chatUpdatesQueue.add(a0);
} else {
L4: {
if (a0.isLoadingAtTop) {
if (!ref6.current && !ref7.current) {
break L4;
}
chatUpdatesQueue.add(a0);
break L7;
}
}
applyNativeRowsUpdate(a0);
}
}
},
handleScrollCallbacks: handleScrollCallbacks2,
handleScroll: handleScroll2,
handleScrollPosition: function handleScrollPosition({ timeStamp, nativeEvent }) {
const { isAtBottom: isAtBottom2, isNearBottom, isNearTop, dragging, decelerating, shouldShowJumpToPresent, isFirstMessageVisible, firstVisibleMessageIndex, firstVisibleMessagePercentVisible, lastVisibleMessageIndex, changesetUpdateId, lastVisibleMessagePercentVisible } = nativeEvent;
const changesetIdForChat = getChangesetIdForChat(chatRef.current);
if (changesetUpdateId !== changesetIdForChat) {
if (ref.current == null) {
ref.current = timeStamp;
}
if (isStaff) {
c7341_6.log("STAFF-ACK-LOG: Ignoring outdated scroll event.", channelId, changesetUpdateId, changesetIdForChat, timeStamp);
}
return void 0;
}
handleVisibleMessagesChange({
firstVisibleMessageRowIndex: firstVisibleMessageIndex,
lastVisibleMessageRowIndex: lastVisibleMessageIndex,
firstVisibleMessagePercentVisible,
lastVisibleMessagePercentVisible,
source: QuestsVisibleMessagesChangedSource.SCROLL
});
let current = ref.current;
if (current == null) {
current = timeStamp;
}
ref.current = void 0;
handleScroll2({
eventTimestamp: current,
isAtBottom: isAtBottom2,
isNearBottom,
isNearTop,
dragging,
decelerating,
shouldShowJumpToPresent,
isFirstMessageVisible
});
visibleMessagesWindowHandler.handleScrollPosition({
rows: chatManager._rows,
firstVisibleMessageRowIndex: firstVisibleMessageIndex,
lastVisibleMessageRowIndex: lastVisibleMessageIndex
});
}
};
};