decord/alpha/source/modules/chat/native/computeScrollData.tsx

107 lines
3.4 KiB
TypeScript
Raw Normal View History

// Module ID: 11045
// Function ID: 11046
2026-07-29 08:29:29 +00:00
// Name: computeScrollData
// Dependencies: [4855, 7570, 11046, 4793, 2]
2026-07-29 08:29:29 +00:00
// Exports: default, findMessageRowIndex
2026-07-20 16:05:17 +00:00
// Module 11045 (computeScrollData)
import NativeChatUtils from "NativeChatUtils" /* 11046 */;
import AccessibilityStore from "AccessibilityStore" /* 4855 */;
2026-07-23 10:11:24 +00:00
require = fn;
const RowGeneratorConstants = fn(7570);
({ RowType: c3, SeparatorType: closure_4 } = RowGeneratorConstants);
const size = fn(2);
const result = size.fileFinishedImporting("modules/chat/native/computeScrollData.tsx");
2026-07-20 16:05:17 +00:00
export default function computeScrollData(shouldInitialScroll) {
({ rows, scrollToMessageId, jumpTargetId, animated, scrollPosition, focusTargetId, jumpType } = shouldInitialScroll);
if (shouldInitialScroll.shouldInitialScroll) {
if (null == jumpTargetId) {
2026-07-29 08:29:29 +00:00
const findIndexResult = rows.findIndex((type) => {
let tmp = type.type === constants.SEPARATOR;
if (tmp) {
tmp = type.id === constants2.UNREAD;
}
return tmp;
});
let tmp3;
if (-1 !== findIndexResult) {
tmp3 = findIndexResult;
}
if (null != tmp3) {
const obj2 = { type: NativeChatUtils.ChatScrollType.SCROLL, index: tmp3, animate: null, highlight: false, position: null };
2026-07-20 16:05:17 +00:00
if (animated) {
animated = !AccessibilityStore.useReducedMotion;
2026-07-20 16:05:17 +00:00
}
obj2.animate = animated;
obj2.position = NativeChatUtils.ChatScrollPosition.TOP;
return obj2;
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
let tmp4;
2026-07-20 16:05:17 +00:00
if (null != scrollToMessageId) {
2026-07-29 08:29:29 +00:00
focusTargetId = scrollToMessageId;
const findIndexResult1 = rows.findIndex((message) => {
let tmp = null != message.message;
if (tmp) {
tmp = message.message.id === focusTargetId;
}
return tmp;
});
let tmp6;
if (-1 !== findIndexResult1) {
tmp6 = findIndexResult1;
}
if (null != tmp6) {
const obj = { type: NativeChatUtils.ChatScrollType.SCROLL, index: tmp6, animate: null, highlight: null, position: null };
const useReducedMotion = AccessibilityStore.useReducedMotion;
2026-07-29 08:29:29 +00:00
let tmp10 = !useReducedMotion;
if (!useReducedMotion) {
tmp10 = jumpType !== tmp7(4793).JumpType.INSTANT;
2026-07-20 16:05:17 +00:00
}
obj.animate = tmp10;
obj.highlight = scrollToMessageId === jumpTargetId;
2026-07-29 08:29:29 +00:00
if (scrollPosition == null) {
scrollPosition = tmp7(11046).ChatScrollPosition.TOP;
2026-07-20 16:05:17 +00:00
}
obj.position = scrollPosition;
2026-07-29 08:29:29 +00:00
tmp4 = obj;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
if (null == tmp4) {
let tmp11;
2026-07-20 16:05:17 +00:00
if (null != focusTargetId) {
2026-07-29 08:29:29 +00:00
const findIndexResult2 = rows.findIndex((message) => {
let tmp = null != message.message;
if (tmp) {
tmp = message.message.id === focusTargetId;
}
return tmp;
});
let tmp13;
if (-1 !== findIndexResult2) {
tmp13 = findIndexResult2;
}
if (null != tmp13) {
const obj3 = { type: NativeChatUtils.ChatScrollType.FOCUS_ONLY, index: tmp13 };
tmp11 = obj3;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
tmp4 = tmp11;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp4;
};
export const findMessageRowIndex = function findMessageRowIndex(previousRows, ChatTTITracker) {
2026-08-24 06:08:38 +00:00
closure_0 = ChatTTITracker;
2026-07-29 08:29:29 +00:00
const findIndexResult = previousRows.findIndex((message) => {
let tmp = null != message.message;
if (tmp) {
tmp = message.message.id === focusTargetId;
}
return tmp;
});
return -1 !== findIndexResult ? findIndexResult : undefined;
2026-07-20 16:05:17 +00:00
};