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

110 lines
3.5 KiB
TypeScript
Raw Normal View History

// Module ID: 11049
// Function ID: 11050
2026-07-29 08:29:29 +00:00
// Name: computeScrollData
// Dependencies: [4834, 7548, 11050, 4772, 2]
2026-07-29 08:29:29 +00:00
// Exports: default, findMessageRowIndex
2026-07-20 16:05:17 +00:00
// Module 11049 (computeScrollData)
import NativeChatUtils from "NativeChatUtils" /* 11050 */;
import AccessibilityStore from "AccessibilityStore" /* 4834 */;
2026-07-23 10:11:24 +00:00
require = fn;
const RowGeneratorConstants = fn(7548);
({ 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, scrollToRowIndexOverride, jumpType } = shouldInitialScroll);
2026-07-20 16:05:17 +00:00
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) {
if (scrollToRowIndexOverride == null) {
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;
2026-07-29 08:29:29 +00:00
}
scrollToRowIndexOverride = tmp6;
2026-07-29 08:29:29 +00:00
}
if (null != scrollToRowIndexOverride) {
const obj = { type: NativeChatUtils.ChatScrollType.SCROLL, index: scrollToRowIndexOverride, 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(4772).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(11050).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, startMessageId) {
closure_0 = startMessageId;
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
};