fix: skip following feed fetch when all tab is active

This commit is contained in:
Julien Calixte
2026-03-10 16:06:35 +01:00
parent cb15eac854
commit 97c6f01e1c
2 changed files with 11 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ import { PublicNoteListItem } from "@/modules/note/models/Note"
import { computedAsync } from "@vueuse/core"
import { computed, ref, Ref, watch } from "vue"
export function useFollowingNoteList(dids: Ref<Set<string>>) {
export function useFollowingNoteList(dids: Ref<Set<string>>, enabled: Ref<boolean>) {
const isLoading = ref(false)
const notes = ref<PublicNoteListItem[]>([])
const cursor = ref<string | null | undefined>(null)
@@ -38,11 +38,18 @@ export function useFollowingNoteList(dids: Ref<Set<string>>) {
}
watch(dids, (newDids) => {
if (!enabled.value) return
if (newDids.size > 0 && notes.value.length === 0) {
onLoadMore()
}
})
watch(enabled, (isEnabled) => {
if (isEnabled && dids.value.size > 0 && notes.value.length === 0) {
onLoadMore()
}
})
const authors = computedAsync<Map<string, Author>>(async () => {
if (notes.value.length === 0) return new Map()
return getAuthors(new Set(notes.value.map((n) => n.did)))

View File

@@ -23,8 +23,10 @@ const tab = computed<"all" | "following">({
}),
})
const followingEnabled = computed(() => tab.value === 'following')
const all = usePublicNoteList()
const following = useFollowingNoteList(follows)
const following = useFollowingNoteList(follows, followingEnabled)
</script>
<template>