fix: prevent double API call on library load

- remove racy watch(loading)+loadIfSentinelVisible fallback that fired before RecycleScroller set virtual height
- add hasMore guard and total reset in useBookQuery for defensive correctness
This commit is contained in:
neon
2026-03-29 15:26:13 -06:00
parent 399fa179d2
commit e2d0789851
2 changed files with 2 additions and 16 deletions
@@ -19,12 +19,14 @@ export function useBookQuery(libraryId: Ref<number | null>) {
async function load(reset = false) {
if (loading.value || libraryId.value === null) return
if (!reset && !hasMore.value) return
loading.value = true
error.value = null
if (reset) {
pagination.page = 0
items.value = []
total.value = 0
}
try {
-16
View File
@@ -196,14 +196,6 @@ function clearFilters() {
const sentinel = ref<HTMLElement | null>(null)
let observer: IntersectionObserver | null = null
function loadIfSentinelVisible() {
if (!hasMore.value || loading.value) return
const el = sentinel.value
if (!el) return
const rect = el.getBoundingClientRect()
if (rect.top < window.innerHeight + 300) load()
}
onMounted(() => {
load(true)
@@ -233,14 +225,6 @@ watch(libraryId, (newId) => {
watch(filter, () => load(true), { deep: true })
watch(
loading,
(isLoading) => {
if (!isLoading) loadIfSentinelVisible()
},
{ flush: 'post' },
)
const { selectionMode, selectedIds, selectedCount, enterSelectionMode, exitSelectionMode, toggleBook, rangeSelectTo, isSelected } = useBookSelection()
const {
pendingId: deleteBookId,