🚸 优化滚动处理,移除不必要的async/await

This commit is contained in:
BTMuli
2025-11-25 21:18:09 +08:00
parent 4d937b365b
commit 50a528d25b
2 changed files with 5 additions and 5 deletions

View File

@@ -118,18 +118,18 @@ watch(
},
);
async function handleListScroll(e: Event): Promise<void> {
function handleListScroll(e: Event): void {
const target = <HTMLElement>e.target;
if (!target) return;
// Emit event to close sub-reply menus when parent scrolls
await emit("closeReplySub");
emit("closeReplySub");
// Check if scrolled to bottom for auto-load
const scrollTop = target.scrollTop;
const clientHeight = target.clientHeight;
const scrollHeight = target.scrollHeight;
if (scrollTop + clientHeight >= scrollHeight - 1) {
if (!loading.value && !isLast.value) {
await loadReply();
loadReply();
}
}
}

View File

@@ -181,7 +181,7 @@ async function listenCloseSub(): Promise<UnlistenFn> {
});
}
async function handleSubScroll(e: globalThis.Event): Promise<void> {
function handleSubScroll(e: globalThis.Event): void {
const target = <HTMLElement>e.target;
if (!target) return;
// Check if scrolled to bottom for auto-load
@@ -190,7 +190,7 @@ async function handleSubScroll(e: globalThis.Event): Promise<void> {
const scrollHeight = target.scrollHeight;
if (scrollTop + clientHeight >= scrollHeight - 1) {
if (!loading.value && !isLast.value) {
await loadSub();
loadSub();
}
}
}