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

93 lines
3 KiB
TypeScript
Raw Normal View History

2026-07-24 07:16:23 +00:00
// Module ID: 9475
// Function ID: 73680
2026-07-20 16:05:17 +00:00
// Name: findMessageRowIndex
2026-07-24 07:16:23 +00:00
// Dependencies: [4122, 7711, 9476, 4062, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-07-24 07:16:23 +00:00
// Module 9475 (findMessageRowIndex)
2026-07-23 10:11:24 +00:00
import _isNativeReflectConstruct from "_isNativeReflectConstruct";
import Changeset from "Changeset";
let closure_3;
let closure_4;
const require = arg1;
2026-07-20 16:05:17 +00:00
function findMessageRowIndex(rows, focusTargetId) {
2026-07-23 10:11:24 +00:00
let closure_0 = focusTargetId;
2026-07-20 16:05:17 +00:00
const findIndexResult = rows.findIndex((message) => {
let tmp = null != message.message;
if (tmp) {
2026-07-23 10:11:24 +00:00
tmp = message.message.id === closure_0;
2026-07-20 16:05:17 +00:00
}
return tmp;
});
return -1 !== findIndexResult ? findIndexResult : undefined;
}
2026-07-23 10:11:24 +00:00
({ RowType: closure_3, SeparatorType: closure_4 } = Changeset);
const result = require("ChatScrollPosition").fileFinishedImporting("modules/chat/native/computeScrollData.tsx");
2026-07-20 16:05:17 +00:00
export default function computeScrollData(shouldInitialScroll) {
let animated;
let focusTargetId;
let jumpTargetId;
let jumpType;
let rows;
let scrollPosition;
let scrollToMessageId;
({ rows, scrollToMessageId, jumpTargetId, animated, scrollPosition, focusTargetId, jumpType } = shouldInitialScroll);
if (shouldInitialScroll.shouldInitialScroll) {
if (null == jumpTargetId) {
2026-07-23 10:11:24 +00:00
const tmp2 = (function findUnreadSeperatorRowIndex(rows) {
2026-07-20 16:05:17 +00:00
const findIndexResult = rows.findIndex((type) => {
2026-07-23 10:11:24 +00:00
let tmp = type.type === outer2_3.SEPARATOR;
2026-07-20 16:05:17 +00:00
if (tmp) {
2026-07-23 10:11:24 +00:00
tmp = type.id === outer2_4.UNREAD;
2026-07-20 16:05:17 +00:00
}
return tmp;
});
return -1 !== findIndexResult ? findIndexResult : undefined;
2026-07-23 10:11:24 +00:00
})(rows);
2026-07-20 16:05:17 +00:00
if (null != tmp2) {
2026-07-24 07:16:23 +00:00
let obj = { type: require(9476) /* ChatScrollPosition */.ChatScrollType.SCROLL, index: tmp2 };
2026-07-20 16:05:17 +00:00
if (animated) {
2026-07-23 10:11:24 +00:00
animated = !_isNativeReflectConstruct.useReducedMotion;
2026-07-20 16:05:17 +00:00
}
obj.animate = animated;
obj.highlight = false;
2026-07-24 07:16:23 +00:00
obj.position = require(9476) /* ChatScrollPosition */.ChatScrollPosition.TOP;
2026-07-20 16:05:17 +00:00
return obj;
}
}
}
let tmp3;
if (null != scrollToMessageId) {
const tmp5 = findMessageRowIndex(rows, scrollToMessageId);
if (null != tmp5) {
2026-07-24 07:16:23 +00:00
obj = { type: require(9476) /* ChatScrollPosition */.ChatScrollType.SCROLL, index: tmp5 };
2026-07-23 10:11:24 +00:00
let tmp9 = !_isNativeReflectConstruct.useReducedMotion;
2026-07-20 16:05:17 +00:00
if (tmp9) {
2026-07-23 10:11:24 +00:00
tmp9 = jumpType !== require(4062) /* GuildThemeSourcePreference */.JumpType.INSTANT;
2026-07-20 16:05:17 +00:00
}
obj.animate = tmp9;
obj.highlight = scrollToMessageId === jumpTargetId;
if (null == scrollPosition) {
2026-07-24 07:16:23 +00:00
scrollPosition = require(9476) /* ChatScrollPosition */.ChatScrollPosition.TOP;
2026-07-20 16:05:17 +00:00
}
obj.position = scrollPosition;
tmp3 = obj;
}
}
if (null == tmp3) {
let tmp14;
if (null != focusTargetId) {
const tmp16 = findMessageRowIndex(rows, focusTargetId);
if (null != tmp16) {
2026-07-24 07:16:23 +00:00
obj = { type: require(9476) /* ChatScrollPosition */.ChatScrollType.FOCUS_ONLY, index: tmp16 };
2026-07-20 16:05:17 +00:00
tmp14 = obj;
}
}
tmp3 = tmp14;
}
return tmp3;
};
export { findMessageRowIndex };