feat: sync public notes tab with URL search params
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user