feat: sync public notes tab with URL search params

This commit is contained in:
Julien Calixte
2026-03-10 15:32:44 +01:00
parent c721338dc0
commit 72d0478b6f

View File

@@ -5,12 +5,19 @@ import SignInAtproto from "@/components/SignInAtproto.vue"
import { useATProtoLogin } from "@/hooks/useATProtoLogin.hook" import { useATProtoLogin } from "@/hooks/useATProtoLogin.hook"
import { useFollows } from "@/hooks/useFollows.hook" import { useFollows } from "@/hooks/useFollows.hook"
import { usePublicNoteList } from "@/hooks/usePublicNoteList.hook" import { usePublicNoteList } from "@/hooks/usePublicNoteList.hook"
import { ref } from "vue" import { computed } from "vue"
import { useRoute, useRouter } from "vue-router"
const route = useRoute()
const router = useRouter()
const { did, isLoggedIn } = useATProtoLogin() const { did, isLoggedIn } = useATProtoLogin()
const { follows } = useFollows(did) const { follows } = useFollows(did)
const tab = ref<'all' | 'following'>('all') const tab = computed<'all' | 'following'>({
get: () => route.query.tab === 'following' ? 'following' : 'all',
set: (value) => router.replace({ query: { ...route.query, tab: value === 'all' ? undefined : value } }),
})
const all = usePublicNoteList() const all = usePublicNoteList()
const following = usePublicNoteList({ followsFilter: follows }) const following = usePublicNoteList({ followsFilter: follows })
@@ -27,6 +34,7 @@ const following = usePublicNoteList({ followsFilter: follows })
<div v-if="isLoggedIn" role="tablist" class="tabs tabs-border"> <div v-if="isLoggedIn" role="tablist" class="tabs tabs-border">
<a role="tab" class="tab" :class="{ 'tab-active': tab === 'all' }" @click="tab = 'all'">All</a> <a role="tab" class="tab" :class="{ 'tab-active': tab === 'all' }" @click="tab = 'all'">All</a>
<a role="tab" class="tab" :class="{ 'tab-active': tab === 'following' }" @click="tab = 'following'">Following</a> <a role="tab" class="tab" :class="{ 'tab-active': tab === 'following' }" @click="tab = 'following'">Following</a>
</div> </div>
<PublicNoteList <PublicNoteList