fix: fetch for followed tags needs authorized session

This commit is contained in:
Ayo Ayco 2025-04-27 21:16:50 +02:00
parent b82e85585c
commit 53c3be3a87
5 changed files with 20 additions and 5 deletions

View file

@ -11,7 +11,10 @@ function reorderAndFilter(items: mastodon.v1.Status[]) {
return reorderedTimeline(items, 'home')
}
const followedTags = (await useMasto().client.value.v1.followedTags.list({ limit: 0 }))
let followedTags: mastodon.v1.Tag[] | undefined
if (currentUser.value !== undefined) {
followedTags = (await useMasto().client.value.v1.followedTags.list({ limit: 0 }))
}
</script>
<template>

View file

@ -25,7 +25,7 @@ const showOriginSite = computed(() =>
function getFollowedTag(status: mastodon.v1.Status): string | null {
const followedTagNames = followedTags.map(tag => tag.name)
const followedStatusTags = status.tags.filter(tag => followedTagNames.includes(tag.name))
return followedStatusTags.length ? followedStatusTags[0]?.name : null
return followedStatusTags.length > 0 ? followedStatusTags[0]?.name : null
}
</script>

View file

@ -7,7 +7,10 @@ function reorderAndFilter(items: mastodon.v1.Status[]) {
return reorderedTimeline(items, 'public')
}
const followedTags = (await useMasto().client.value.v1.followedTags.list({ limit: 0 }))
let followedTags: mastodon.v1.Tag[] | undefined
if (currentUser.value !== undefined) {
followedTags = (await useMasto().client.value.v1.followedTags.list({ limit: 0 }))
}
</script>
<template>

View file

@ -7,7 +7,10 @@ function reorderAndFilter(items: mastodon.v1.Status[]) {
return reorderedTimeline(items, 'public')
}
const followedTags = (await useMasto().client.value.v1.followedTags.list({ limit: 0 }))
let followedTags: mastodon.v1.Tag[] | undefined
if (currentUser.value !== undefined) {
followedTags = (await useMasto().client.value.v1.followedTags.list({ limit: 0 }))
}
</script>
<template>

View file

@ -1,4 +1,6 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
definePageMeta({
name: 'tag',
})
@ -23,7 +25,11 @@ onReactivated(() => {
// The user will see the previous content first, and any changes will be updated to the UI when the request is completed
refresh()
})
const followedTags = (await useMasto().client.value.v1.followedTags.list({ limit: 0 }))
let followedTags: mastodon.v1.Tag[] | undefined
if (currentUser.value !== undefined) {
followedTags = (await useMasto().client.value.v1.followedTags.list({ limit: 0 }))
}
</script>
<template>