refactor: sync masto (#1121)
This commit is contained in:
parent
eb1f769e32
commit
4422a57f49
81 changed files with 397 additions and 367 deletions
|
@ -15,13 +15,13 @@ const publishWidget = ref()
|
|||
const { data: status, pending, refresh: refreshStatus } = useAsyncData(
|
||||
`status:${id}`,
|
||||
() => fetchStatus(id),
|
||||
{ watch: [isMastoInitialised], immediate: isMastoInitialised.value },
|
||||
{ watch: [isHydrated], immediate: isHydrated.value },
|
||||
)
|
||||
const masto = useMasto()
|
||||
const { client } = $(useMasto())
|
||||
const { data: context, pending: pendingContext, refresh: refreshContext } = useAsyncData(
|
||||
`context:${id}`,
|
||||
async () => masto.v1.statuses.fetchContext(id),
|
||||
{ watch: [isMastoInitialised], immediate: isMastoInitialised.value },
|
||||
async () => client.v1.statuses.fetchContext(id),
|
||||
{ watch: [isHydrated], immediate: isHydrated.value },
|
||||
)
|
||||
|
||||
const replyDraft = $computed(() => status.value ? getReplyDraft(status.value) : null)
|
||||
|
|
|
@ -8,7 +8,7 @@ const accountName = $(computedEager(() => toShortHandle(params.account as string
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
const { data: account, pending, refresh } = $(await useAsyncData(() => fetchAccountByHandle(accountName).catch(() => null), { watch: [isMastoInitialised], immediate: isMastoInitialised.value }))
|
||||
const { data: account, pending, refresh } = $(await useAsyncData(() => fetchAccountByHandle(accountName).catch(() => null), { immediate: process.client }))
|
||||
const relationship = $computed(() => account ? useRelationship(account).value : undefined)
|
||||
|
||||
onReactivated(() => {
|
||||
|
|
|
@ -6,7 +6,7 @@ const handle = $(computedEager(() => params.account as string))
|
|||
definePageMeta({ name: 'account-followers' })
|
||||
|
||||
const account = await fetchAccountByHandle(handle)
|
||||
const paginator = account ? useMasto().v1.accounts.listFollowers(account.id, {}) : null
|
||||
const paginator = account ? useMastoClient().v1.accounts.listFollowers(account.id, {}) : null
|
||||
|
||||
const isSelf = useSelfAccount(account)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ const handle = $(computedEager(() => params.account as string))
|
|||
definePageMeta({ name: 'account-following' })
|
||||
|
||||
const account = await fetchAccountByHandle(handle)
|
||||
const paginator = account ? useMasto().v1.accounts.listFollowing(account.id, {}) : null
|
||||
const paginator = account ? useMastoClient().v1.accounts.listFollowing(account.id, {}) : null
|
||||
|
||||
const isSelf = useSelfAccount(account)
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ const { t } = useI18n()
|
|||
|
||||
const account = await fetchAccountByHandle(handle)
|
||||
|
||||
const paginator = useMasto().v1.accounts.listStatuses(account.id, { limit: 30, excludeReplies: true })
|
||||
const paginator = useMastoClient().v1.accounts.listStatuses(account.id, { limit: 30, excludeReplies: true })
|
||||
|
||||
if (account) {
|
||||
useHeadFixed({
|
||||
|
|
|
@ -7,7 +7,7 @@ const handle = $(computedEager(() => params.account as string))
|
|||
|
||||
const account = await fetchAccountByHandle(handle)
|
||||
|
||||
const paginator = useMasto().v1.accounts.listStatuses(account.id, { onlyMedia: true, excludeReplies: false })
|
||||
const paginator = useMastoClient().v1.accounts.listStatuses(account.id, { onlyMedia: true, excludeReplies: false })
|
||||
|
||||
if (account) {
|
||||
useHeadFixed({
|
||||
|
|
|
@ -7,7 +7,7 @@ const handle = $(computedEager(() => params.account as string))
|
|||
|
||||
const account = await fetchAccountByHandle(handle)
|
||||
|
||||
const paginator = useMasto().v1.accounts.listStatuses(account.id, { excludeReplies: false })
|
||||
const paginator = useMastoClient().v1.accounts.listStatuses(account.id, { excludeReplies: false })
|
||||
|
||||
if (account) {
|
||||
useHeadFixed({
|
||||
|
|
|
@ -18,7 +18,7 @@ const tabs = $computed(() => [
|
|||
{
|
||||
to: isHydrated.value ? `/${currentServer.value}/explore/users` : '/explore/users',
|
||||
display: isHydrated.value ? t('tab.for_you') : '',
|
||||
disabled: !isMastoInitialised.value || !currentUser.value,
|
||||
disabled: !isHydrated.value || !currentUser.value,
|
||||
},
|
||||
] as const)
|
||||
</script>
|
||||
|
@ -35,6 +35,6 @@ const tabs = $computed(() => [
|
|||
<template #header>
|
||||
<CommonRouteTabs replace :options="tabs" />
|
||||
</template>
|
||||
<NuxtPage v-if="isMastoInitialised" />
|
||||
<NuxtPage v-if="isHydrated" />
|
||||
</MainContent>
|
||||
</template>
|
||||
|
|
|
@ -3,7 +3,7 @@ import { STORAGE_KEY_HIDE_EXPLORE_POSTS_TIPS } from '~~/constants'
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
const paginator = useMasto().v1.trends.listStatuses()
|
||||
const paginator = useMastoClient().v1.trends.listStatuses()
|
||||
|
||||
const hideNewsTips = useLocalStorage(STORAGE_KEY_HIDE_EXPLORE_POSTS_TIPS, false)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import { STORAGE_KEY_HIDE_EXPLORE_NEWS_TIPS } from '~~/constants'
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
const paginator = useMasto().v1.trends.listLinks()
|
||||
const paginator = useMastoClient().v1.trends.listLinks()
|
||||
|
||||
const hideNewsTips = useLocalStorage(STORAGE_KEY_HIDE_EXPLORE_NEWS_TIPS, false)
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ import { STORAGE_KEY_HIDE_EXPLORE_TAGS_TIPS } from '~~/constants'
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
const masto = useMasto()
|
||||
const paginator = masto.v1.trends.listTags({
|
||||
const { client } = $(useMasto())
|
||||
const paginator = client.v1.trends.listTags({
|
||||
limit: 20,
|
||||
})
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
const { t } = useI18n()
|
||||
|
||||
// limit: 20 is the default configuration of the official client
|
||||
const paginator = useMasto().v2.suggestions.list({ limit: 20 })
|
||||
const paginator = useMastoClient().v2.suggestions.list({ limit: 20 })
|
||||
|
||||
useHeadFixed({
|
||||
title: () => `${t('tab.for_you')} | ${t('nav.explore')}`,
|
||||
|
|
|
@ -17,6 +17,6 @@ useHeadFixed({
|
|||
</NuxtLink>
|
||||
</template>
|
||||
|
||||
<TimelinePublic v-if="isMastoInitialised" />
|
||||
<TimelinePublic v-if="isHydrated" />
|
||||
</MainContent>
|
||||
</template>
|
||||
|
|
|
@ -16,6 +16,6 @@ useHeadFixed({
|
|||
</NuxtLink>
|
||||
</template>
|
||||
|
||||
<TimelinePublicLocal v-if="isMastoInitialised" />
|
||||
<TimelinePublicLocal v-if="isHydrated" />
|
||||
</MainContent>
|
||||
</template>
|
||||
|
|
|
@ -6,12 +6,11 @@ definePageMeta({
|
|||
const params = useRoute().params
|
||||
const tagName = $(computedEager(() => params.tag as string))
|
||||
|
||||
const masto = useMasto()
|
||||
const { data: tag, refresh } = $(await useAsyncData(() => masto.v1.tags.fetch(tagName), { watch: [isMastoInitialised], immediate: isMastoInitialised.value }))
|
||||
const { client } = $(useMasto())
|
||||
const { data: tag, refresh } = $(await useAsyncData(() => client.v1.tags.fetch(tagName)))
|
||||
|
||||
const paginator = masto.v1.timelines.listHashtag(tagName)
|
||||
const stream = masto.v1.stream.streamTagTimeline(tagName)
|
||||
onBeforeUnmount(() => stream.then(s => s.disconnect()))
|
||||
const paginator = client.v1.timelines.listHashtag(tagName)
|
||||
const stream = useStreaming(client => client.v1.stream.streamTagTimeline(tagName))
|
||||
|
||||
if (tag) {
|
||||
useHeadFixed({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue