decord/source/modules/messages/native/hooks/useScrollHandlers.tsx

258 lines
8.7 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 10773
// Function ID: 10774
2026-07-20 16:05:17 +00:00
// Name: useScrollHandlers
2026-08-24 06:08:38 +00:00
// Dependencies: [19, 8719, 3, 4727, 9132, 705, 10512, 10514, 6756, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-08-24 06:08:38 +00:00
// Module 10773 (useScrollHandlers)
import timestampDefault from "timestamp" /* 3 */;
import closure_3 from "noop" /* 19 */;
import updateChatInputContainerHeight from "updateChatInputContainerHeight" /* 8719 */;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-29 08:29:29 +00:00
({ updateIsAtBottom: c4, updateShouldShowJumpToPresentButton: c5 } = updateChatInputContainerHeight);
2026-08-24 06:08:38 +00:00
let closure_6 = new timestampDefault("useScrollHandlers");
let tmp3 = new timestampDefault("useScrollHandlers");
let result = require("set").fileFinishedImporting("modules/messages/native/hooks/useScrollHandlers.tsx");
2026-07-20 16:05:17 +00:00
export default function useScrollHandlers(arg0) {
2026-08-24 06:08:38 +00:00
({ chatRef: require, chatManager: importDefault, chatUpdatesQueue: dependencyMap, pendingUpdatesQueueRef: closure_3, animatedRef: closure_4, fetchMoreBefore: closure_5, fetchMoreAfter: closure_6, handleVisibleMessagesChange: closure_7, applyNativeRowsUpdate: closure_8, messages: closure_9, channel: closure_10, channelId: closure_11, screenIndex: closure_12, onScroll: closure_13, useReducedMotion: closure_14, isStaff: closure_15, visibleMessagesWindowHandler: closure_16 } = arg0);
2026-07-29 08:29:29 +00:00
let ref;
2026-07-20 16:05:17 +00:00
let ref1;
let ref2;
let ref3;
let ref4;
let ref5;
let ref6;
function handleScrollCallbacks(isNearTop) {
({ eventTimestamp, isAtBottom, isNearBottom } = isNearTop);
if (isNearBottom === undefined) {
isNearBottom = false;
}
let flag = isNearTop.isNearTop;
if (flag === undefined) {
flag = false;
}
let flag2 = isNearTop.dragging;
if (flag2 === undefined) {
flag2 = false;
}
let flag3 = isNearTop.decelerating;
if (flag3 === undefined) {
flag3 = false;
}
let flag4 = isNearTop.isFirstMessageVisible;
if (flag4 === undefined) {
flag4 = false;
}
2026-07-29 08:29:29 +00:00
if (null != closure_10) {
2026-08-24 06:08:38 +00:00
closure_1_0(closure_1_2[3]);
2026-07-29 08:29:29 +00:00
const loadingMore = tmp29.loadingMore;
let tmp6 = !loadingMore;
if (!loadingMore) {
2026-07-20 16:05:17 +00:00
if (!flag2) {
flag2 = flag3;
}
if (!flag2) {
flag2 = tmp5;
}
2026-07-29 08:29:29 +00:00
tmp6 = flag2;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp6) {
tmp6 = 0 === ref.current.length;
2026-07-20 16:05:17 +00:00
}
if (!ref4.current) {
if (flag) {
2026-07-29 08:29:29 +00:00
if (tmp29.hasMoreBefore) {
if (tmp6) {
closure_4.current = true;
callback();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let obj = { isFirstMessageVisible: null };
obj[0] = flag4;
2026-07-23 10:11:24 +00:00
callback5(obj);
2026-07-29 08:29:29 +00:00
closure_2.tryFlush();
2026-07-20 16:05:17 +00:00
return true;
}
}
}
if (!ref3.current) {
if (isNearBottom) {
2026-07-29 08:29:29 +00:00
if (tmp29.hasMoreAfter) {
if (tmp6) {
closure_4.current = true;
callback2();
2026-07-20 16:05:17 +00:00
}
}
}
}
let current = ref2.current === isAtBottom;
if (current) {
current = ref1.current;
}
if (!current) {
2026-08-24 06:08:38 +00:00
obj = closure_1_1(tmp3[4]);
2026-07-29 08:29:29 +00:00
const id = tmp.id;
let num = 0;
2026-07-20 16:05:17 +00:00
if (isAtBottom) {
2026-07-29 08:29:29 +00:00
num = 1;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const result = obj.updateChannelDimensions(id, eventTimestamp, num, 1, 0);
2026-07-20 16:05:17 +00:00
ref1.current = true;
}
2026-08-24 06:08:38 +00:00
tmp3 = closure_1_2;
2026-07-20 16:05:17 +00:00
}
return false;
}
function handleScroll(eventTimestamp) {
const isAtBottom = eventTimestamp.isAtBottom;
2026-07-29 08:29:29 +00:00
let isNearBottom = eventTimestamp.isNearBottom;
if (isNearBottom === undefined) {
isNearBottom = false;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let isNearTop = eventTimestamp.isNearTop;
if (isNearTop === undefined) {
isNearTop = false;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let dragging = eventTimestamp.dragging;
if (dragging === undefined) {
dragging = false;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let decelerating = eventTimestamp.decelerating;
if (decelerating === undefined) {
decelerating = false;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let shouldShowJumpToPresent = eventTimestamp.shouldShowJumpToPresent;
if (shouldShowJumpToPresent === undefined) {
shouldShowJumpToPresent = false;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let isFirstMessageVisible = eventTimestamp.isFirstMessageVisible;
if (isFirstMessageVisible === undefined) {
isFirstMessageVisible = false;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (handleScrollCallbacks({ eventTimestamp: eventTimestamp.eventTimestamp, isAtBottom, isNearBottom, isNearTop, dragging, decelerating, shouldShowJumpToPresent, isFirstMessageVisible })) {
2026-07-20 16:05:17 +00:00
ref2.current = isAtBottom;
2026-07-29 08:29:29 +00:00
ref3.current = isNearBottom;
ref4.current = isNearTop;
ref6.current = dragging;
ref5.current = decelerating;
2026-08-24 06:08:38 +00:00
closure_1_0(closure_1_2[5]).batchUpdates(() => {
2026-07-29 08:29:29 +00:00
let hasMoreAfter = shouldShowJumpToPresent;
if (!shouldShowJumpToPresent) {
2026-08-24 06:08:38 +00:00
hasMoreAfter = closure_1_9.hasMoreAfter;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
closure_2_5(closure_1_11, closure_1_12, hasMoreAfter);
closure_2_4(closure_1_12, isAtBottom);
2026-07-20 16:05:17 +00:00
});
2026-08-24 06:08:38 +00:00
const obj = closure_1_0(closure_1_2[5]);
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
ref = React.useRef(undefined);
2026-07-20 16:05:17 +00:00
ref1 = React.useRef(false);
ref2 = React.useRef(false);
ref3 = React.useRef(false);
ref4 = React.useRef(false);
ref5 = React.useRef(false);
ref6 = React.useRef(false);
return {
hasHandledScrollRef: ref1,
isAtBottomRef: ref2,
isNearBottomRef: ref3,
isNearTopRef: ref4,
deceleratingRef: ref5,
draggingRef: ref6,
firstIgnoredScrollEventTimestampRef: ref,
2026-07-29 08:29:29 +00:00
loadMoreBefore() {
closure_4.current = true;
callback();
},
loadMoreAfter() {
closure_4.current = true;
callback2();
},
2026-07-20 16:05:17 +00:00
scrollToTop() {
let flag = arg0;
if (arg0 === undefined) {
flag = true;
}
if (flag) {
flag = !closure_14;
}
2026-08-24 06:08:38 +00:00
closure_1_1(closure_1_2[6]).scrollToTop(closure_0.current, flag);
2026-07-20 16:05:17 +00:00
},
scrollToRelativeOffset(arg0) {
let flag = arg1;
if (arg1 === undefined) {
flag = true;
}
if (flag) {
flag = !closure_14;
}
2026-08-24 06:08:38 +00:00
const result = closure_1_1(closure_1_2[6]).scrollToRelativeOffset(closure_0.current, arg0, flag);
2026-07-20 16:05:17 +00:00
},
scrollToTopMessage() {
2026-07-23 10:11:24 +00:00
previousRows = previousRows.getPreviousRows();
2026-07-20 16:05:17 +00:00
if (previousRows.length > 0) {
2026-08-24 06:08:38 +00:00
closure_1_1(closure_1_2[6]).scrollTo(closure_0.current, previousRows.length - 1);
const obj = closure_1_1(closure_1_2[6]);
2026-07-20 16:05:17 +00:00
}
},
updateNativeRows(isLoadingAtTop) {
2026-07-29 08:29:29 +00:00
if (closure_2.isBlocking) {
obj.add(isLoadingAtTop);
2026-07-20 16:05:17 +00:00
} else if (!isLoadingAtTop.isLoadingAtTop) {
2026-07-23 10:11:24 +00:00
callback4(isLoadingAtTop);
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
obj.add(isLoadingAtTop);
2026-07-20 16:05:17 +00:00
}
},
handleScrollCallbacks,
handleScroll,
handleScrollPosition(arg0) {
({ timeStamp, nativeEvent } = arg0);
({ firstVisibleMessageIndex, lastVisibleMessageIndex, changesetUpdateId } = nativeEvent);
({ isAtBottom, isNearBottom, isNearTop, dragging, decelerating, shouldShowJumpToPresent, isFirstMessageVisible, firstVisibleMessagePercentVisible, lastVisibleMessagePercentVisible } = nativeEvent);
2026-08-24 06:08:38 +00:00
let obj = closure_1_0(closure_1_2[7]);
2026-07-23 10:11:24 +00:00
const changesetIdForChat = obj.getChangesetIdForChat(closure_0.current);
2026-07-20 16:05:17 +00:00
if (changesetUpdateId !== changesetIdForChat) {
if (null == ref.current) {
ref.current = timeStamp;
}
if (closure_15) {
2026-08-24 06:08:38 +00:00
closure_1_6.log("STAFF-ACK-LOG: Ignoring outdated scroll event.", closure_11, changesetUpdateId, changesetIdForChat, timeStamp);
2026-07-20 16:05:17 +00:00
}
} else {
2026-07-29 08:29:29 +00:00
obj = { firstVisibleMessageRowIndex: null, lastVisibleMessageRowIndex: null, firstVisibleMessagePercentVisible: null, lastVisibleMessagePercentVisible: null, source: null };
obj[0] = firstVisibleMessageIndex;
obj[1] = lastVisibleMessageIndex;
obj[2] = firstVisibleMessagePercentVisible;
obj[3] = lastVisibleMessagePercentVisible;
obj[4] = tmp(tmp2[8]).QuestsVisibleMessagesChangedSource.SCROLL;
2026-07-23 10:11:24 +00:00
callback3(obj);
2026-07-29 08:29:29 +00:00
let current = ref.current;
if (current == null) {
current = timeStamp;
2026-07-20 16:05:17 +00:00
}
ref.current = undefined;
2026-07-29 08:29:29 +00:00
obj = { eventTimestamp: null, isAtBottom: null, isNearBottom: null, isNearTop: null, dragging: null, decelerating: null, shouldShowJumpToPresent: null, isFirstMessageVisible: null };
obj[0] = current;
obj[1] = isAtBottom;
obj[2] = isNearBottom;
obj[3] = isNearTop;
obj[4] = dragging;
obj[5] = decelerating;
obj[6] = shouldShowJumpToPresent;
obj[7] = isFirstMessageVisible;
2026-07-20 16:05:17 +00:00
handleScroll(obj);
2026-08-24 06:08:38 +00:00
obj1 = { rows: null, firstVisibleMessageRowIndex: null, lastVisibleMessageRowIndex: null };
2026-07-29 08:29:29 +00:00
obj1[0] = previousRows._rows;
obj1[1] = firstVisibleMessageIndex;
obj1[2] = lastVisibleMessageIndex;
2026-07-20 16:05:17 +00:00
closure_16.handleScrollPosition(obj1);
}
2026-08-24 06:08:38 +00:00
tmp = closure_1_0;
tmp2 = closure_1_2;
2026-07-20 16:05:17 +00:00
}
};
};