diff --git a/src/hooks/useFollowingNoteList.hook.ts b/src/hooks/useFollowingNoteList.hook.ts index ed54f66..b9cd3e2 100644 --- a/src/hooks/useFollowingNoteList.hook.ts +++ b/src/hooks/useFollowingNoteList.hook.ts @@ -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>) { +export function useFollowingNoteList(dids: Ref>, enabled: Ref) { const isLoading = ref(false) const notes = ref([]) const cursor = ref(null) @@ -38,11 +38,18 @@ export function useFollowingNoteList(dids: Ref>) { } 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>(async () => { if (notes.value.length === 0) return new Map() return getAuthors(new Set(notes.value.map((n) => n.did))) diff --git a/src/views/PublicNoteListView.vue b/src/views/PublicNoteListView.vue index 79e30e3..10eb688 100644 --- a/src/views/PublicNoteListView.vue +++ b/src/views/PublicNoteListView.vue @@ -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)