refactor: inject masto instance via nuxt app (#134)
This commit is contained in:
parent
5c60497421
commit
39b005899e
26 changed files with 67 additions and 48 deletions
|
@ -6,7 +6,7 @@ const id = $computed(() => route.params.status as string)
|
|||
const main = ref<Component | null>(null)
|
||||
|
||||
const status = window.history.state?.status ?? await fetchStatus(id)
|
||||
const { data: context } = useAsyncData(`context:${id}`, () => masto.statuses.fetchContext(id))
|
||||
const { data: context } = useAsyncData(`context:${id}`, () => useMasto().statuses.fetchContext(id))
|
||||
const unsubscribe = watch(context, async (context) => {
|
||||
if (context) {
|
||||
const statusElement = document.querySelector(`#status-${id}`)
|
||||
|
|
|
@ -3,7 +3,7 @@ const params = useRoute().params
|
|||
const accountName = $computed(() => params.account as string)
|
||||
|
||||
const account = await fetchAccountByName(accountName)
|
||||
const paginator = account ? masto.accounts.getFollowersIterable(account.id, {}) : null
|
||||
const paginator = account ? useMasto().accounts.getFollowersIterable(account.id, {}) : null
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -3,7 +3,7 @@ const params = useRoute().params
|
|||
const accountName = $computed(() => params.account as string)
|
||||
|
||||
const account = await fetchAccountByName(accountName)
|
||||
const paginator = account ? masto.accounts.getFollowingIterable(account.id, {}) : null
|
||||
const paginator = account ? useMasto().accounts.getFollowingIterable(account.id, {}) : null
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -8,8 +8,8 @@ const tabNames = ['Posts', 'Posts and replies'] as const
|
|||
// Don't use local storage because it is better to default to Posts every time you visit a user's profile.
|
||||
const tab = $ref('Posts')
|
||||
|
||||
const paginatorPosts = masto.accounts.getStatusesIterable(account.id, { excludeReplies: true })
|
||||
const paginatorPostsWithReply = masto.accounts.getStatusesIterable(account.id, { excludeReplies: false })
|
||||
const paginatorPosts = useMasto().accounts.getStatusesIterable(account.id, { excludeReplies: true })
|
||||
const paginatorPostsWithReply = useMasto().accounts.getStatusesIterable(account.id, { excludeReplies: false })
|
||||
|
||||
const paginator = $computed(() => {
|
||||
return tab === 'Posts' ? paginatorPosts : paginatorPostsWithReply
|
||||
|
|
|
@ -3,7 +3,7 @@ definePageMeta({
|
|||
middleware: 'auth',
|
||||
})
|
||||
|
||||
const paginator = masto.blocks.getIterator()
|
||||
const paginator = useMasto().blocks.getIterator()
|
||||
|
||||
useHead({
|
||||
title: 'Blocked users',
|
||||
|
|
|
@ -3,7 +3,7 @@ definePageMeta({
|
|||
middleware: 'auth',
|
||||
})
|
||||
|
||||
const paginator = masto.bookmarks.getIterator()
|
||||
const paginator = useMasto().bookmarks.getIterator()
|
||||
|
||||
useHead({
|
||||
title: 'Bookmarks',
|
||||
|
|
|
@ -3,7 +3,7 @@ definePageMeta({
|
|||
middleware: 'auth',
|
||||
})
|
||||
|
||||
const paginator = masto.conversations.getIterator()
|
||||
const paginator = useMasto().conversations.getIterator()
|
||||
|
||||
useHead({
|
||||
title: 'Conversations',
|
||||
|
|
|
@ -3,14 +3,14 @@ definePageMeta({
|
|||
middleware: 'auth',
|
||||
})
|
||||
|
||||
const paginator = masto.domainBlocks.getIterator()
|
||||
const paginator = useMasto().domainBlocks.getIterator()
|
||||
|
||||
useHead({
|
||||
title: 'Blocked domains',
|
||||
})
|
||||
|
||||
const unblock = async (domain: string) => {
|
||||
await masto.domainBlocks.unblock(domain)
|
||||
await useMasto().domainBlocks.unblock(domain)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
const paginator = masto.trends.getStatuses()
|
||||
const paginator = useMasto().trends.getStatuses()
|
||||
|
||||
useHead({
|
||||
title: 'Explore',
|
||||
|
|
|
@ -3,7 +3,7 @@ definePageMeta({
|
|||
middleware: 'auth',
|
||||
})
|
||||
|
||||
const paginator = masto.favourites.getIterator()
|
||||
const paginator = useMasto().favourites.getIterator()
|
||||
|
||||
useHead({
|
||||
title: 'Favourites',
|
||||
|
|
|
@ -3,7 +3,7 @@ definePageMeta({
|
|||
middleware: 'auth',
|
||||
})
|
||||
|
||||
const paginator = masto.timelines.getHomeIterable()
|
||||
const paginator = useMasto().timelines.getHomeIterable()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -3,7 +3,7 @@ definePageMeta({
|
|||
middleware: 'auth',
|
||||
})
|
||||
|
||||
const paginator = masto.mutes.getIterator()
|
||||
const paginator = useMasto().mutes.getIterator()
|
||||
|
||||
useHead({
|
||||
title: 'Muted users',
|
||||
|
|
|
@ -9,7 +9,7 @@ const tabNames = ['All', 'Mentions'] as const
|
|||
const tab = $(useLocalStorage<typeof tabNames[number]>(STORAGE_KEY_NOTIFY_TAB, 'All'))
|
||||
|
||||
const paginator = $computed(() => {
|
||||
return masto.notifications.getIterator(tab === 'All' ? undefined : { types: ['mention'] })
|
||||
return useMasto().notifications.getIterator(tab === 'All' ? undefined : { types: ['mention'] })
|
||||
})
|
||||
|
||||
useHead({
|
||||
|
|
|
@ -3,7 +3,7 @@ definePageMeta({
|
|||
middleware: 'auth',
|
||||
})
|
||||
|
||||
const paginator = masto.accounts.getStatusesIterable(currentUser.value!.account.id, { pinned: true })
|
||||
const paginator = useMasto().accounts.getStatusesIterable(currentUser.value!.account.id, { pinned: true })
|
||||
|
||||
useHead({
|
||||
title: 'Pinned',
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
const params = useRoute().params
|
||||
const tag = $computed(() => params.tag as string)
|
||||
|
||||
const paginator = masto.timelines.getHashtagIterable(tag)
|
||||
const paginator = useMasto().timelines.getHashtagIterable(tag)
|
||||
|
||||
useHead({
|
||||
title: `#${tag}`,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue