fix: skip following feed fetch when all tab is active
This commit is contained in:
@@ -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)))
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user