refactor: initialise masto
outside of functions/handlers
This commit is contained in:
parent
03d3775011
commit
720b5114af
13 changed files with 44 additions and 30 deletions
|
@ -17,7 +17,8 @@ const { data: status, pending, refresh: refreshStatus } = useAsyncData(`status:$
|
|||
window.history.state?.status as Status | undefined)
|
||||
?? await fetchStatus(id),
|
||||
)
|
||||
const { data: context, pending: pendingContext, refresh: refreshContext } = useAsyncData(`context:${id}`, () => useMasto().statuses.fetchContext(id))
|
||||
const masto = useMasto()
|
||||
const { data: context, pending: pendingContext, refresh: refreshContext } = useAsyncData(`context:${id}`, () => masto.statuses.fetchContext(id))
|
||||
|
||||
const replyDraft = $computed(() => status.value ? getReplyDraft(status.value) : null)
|
||||
|
||||
|
|
|
@ -4,8 +4,9 @@ import { STORAGE_KEY_HIDE_EXPLORE_TAGS_TIPS } from '~~/constants'
|
|||
|
||||
const { t } = useI18n()
|
||||
|
||||
const masto = useMasto()
|
||||
const { data, pending, error } = useLazyAsyncData(
|
||||
() => useMasto().trends.fetchTags({ limit: 20 }),
|
||||
() => masto.trends.fetchTags({ limit: 20 }),
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
const { t } = useI18n()
|
||||
|
||||
// limit: 20 is the default configuration of the official client
|
||||
const masto = useMasto()
|
||||
const { data, pending, error } = useLazyAsyncData(
|
||||
() => useMasto().suggestions.fetchAll({ limit: 20 }),
|
||||
() => masto.suggestions.fetchAll({ limit: 20 }),
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
const params = useRoute().params
|
||||
const tagName = $(computedEager(() => params.tag as string))
|
||||
|
||||
const { data: tag, refresh } = $(await useAsyncData(() => useMasto().tags.fetch(tagName)))
|
||||
const masto = useMasto()
|
||||
const { data: tag, refresh } = $(await useAsyncData(() => masto.tags.fetch(tagName)))
|
||||
|
||||
const paginator = useMasto().timelines.iterateHashtag(tagName)
|
||||
const stream = await useMasto().stream.streamTagTimeline(tagName)
|
||||
const paginator = masto.timelines.iterateHashtag(tagName)
|
||||
const stream = await masto.stream.streamTagTimeline(tagName)
|
||||
onBeforeUnmount(() => stream.disconnect())
|
||||
|
||||
if (tag) {
|
||||
|
|
|
@ -3,14 +3,15 @@ definePageMeta({
|
|||
middleware: 'auth',
|
||||
})
|
||||
|
||||
const paginator = useMasto().domainBlocks.iterate()
|
||||
const masto = useMasto()
|
||||
const paginator = masto.domainBlocks.iterate()
|
||||
|
||||
useHeadFixed({
|
||||
title: 'Blocked domains',
|
||||
})
|
||||
|
||||
const unblock = async (domain: string) => {
|
||||
await useMasto().domainBlocks.unblock(domain)
|
||||
await masto.domainBlocks.unblock(domain)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -11,8 +11,9 @@ if (useRoute().path === '/signin/callback') {
|
|||
useRouter().push('/home')
|
||||
}
|
||||
|
||||
const paginator = useMasto().timelines.iterateHome()
|
||||
const stream = await useMasto().stream.streamUser()
|
||||
const masto = useMasto()
|
||||
const paginator = masto.timelines.iterateHome()
|
||||
const stream = await masto.stream.streamUser()
|
||||
onBeforeUnmount(() => stream.disconnect())
|
||||
|
||||
const { t } = useI18n()
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
<script setup lang="ts">
|
||||
const { t } = useI18n()
|
||||
const masto = useMasto()
|
||||
|
||||
// Default limit is 20 notifications, and servers are normally caped to 30
|
||||
const paginator = useMasto().notifications.iterate({ limit: 30 })
|
||||
const paginator = masto.notifications.iterate({ limit: 30 })
|
||||
|
||||
const { clearNotifications } = useNotifications()
|
||||
onActivated(clearNotifications)
|
||||
|
||||
const stream = await useMasto().stream.streamUser()
|
||||
const stream = await masto.stream.streamUser()
|
||||
|
||||
useHeadFixed({
|
||||
title: () => `${t('tab.notifications_all')} | ${t('nav_side.notifications')}`,
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
<script setup lang="ts">
|
||||
const { t } = useI18n()
|
||||
|
||||
const masto = useMasto()
|
||||
// Default limit is 20 notifications, and servers are normally caped to 30
|
||||
const paginator = useMasto().notifications.iterate({ limit: 30, types: ['mention'] })
|
||||
const paginator = masto.notifications.iterate({ limit: 30, types: ['mention'] })
|
||||
|
||||
const { clearNotifications } = useNotifications()
|
||||
onActivated(clearNotifications)
|
||||
|
||||
const stream = await useMasto().stream.streamUser()
|
||||
const stream = await masto.stream.streamUser()
|
||||
|
||||
useHeadFixed({
|
||||
title: () => `${t('tab.notifications_mention')} | ${t('nav_side.notifications')}`,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue