fix: remove history state fallback + asyncdata (#687)

zio/stable
Daniel Roe 2023-01-02 01:00:13 +01:00 committed by GitHub
parent 451c4a0701
commit 72ce43dde9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 19 deletions

View File

@ -15,7 +15,7 @@ const publishWidget = ref()
const { data: status, pending, refresh: refreshStatus } = useAsyncData(
`status:${id}`,
async () => (window.history.state?.status as Status | undefined) ?? await fetchStatus(id),
() => fetchStatus(id),
{ watch: [isMastoInitialised], immediate: isMastoInitialised.value },
)
const masto = useMasto()

View File

@ -9,16 +9,13 @@ definePageMeta({ name: 'account-index' })
const { t } = useI18n()
const { data: account } = await useAsyncData(`account:${handle}`, async () => (
window.history.state?.account as Account | undefined)
?? await fetchAccountByHandle(handle),
)
const account = await fetchAccountByHandle(handle)
const paginator = useMasto().accounts.iterateStatuses(account.value!.id, { excludeReplies: true })
const paginator = useMasto().accounts.iterateStatuses(account.id, { excludeReplies: true })
if (account) {
useHeadFixed({
title: () => `${t('account.posts')} | ${getDisplayName(account.value!)} (@${account.value!.acct})`,
title: () => `${t('account.posts')} | ${getDisplayName(account)} (@${account.acct})`,
})
}
</script>

View File

@ -7,16 +7,13 @@ const { t } = useI18n()
const params = useRoute().params
const handle = $(computedEager(() => params.account as string))
const { data: account } = await useAsyncData(`account:${handle}`, async () => (
window.history.state?.account as Account | undefined)
?? await fetchAccountByHandle(handle),
)
const account = await fetchAccountByHandle(handle)
const paginator = useMasto().accounts.iterateStatuses(account.value!.id, { onlyMedia: true, excludeReplies: false })
const paginator = useMasto().accounts.iterateStatuses(account.id, { onlyMedia: true, excludeReplies: false })
if (account) {
useHeadFixed({
title: () => `${t('tab.media')} | ${getDisplayName(account.value!)} (@${account.value!.acct})`,
title: () => `${t('tab.media')} | ${getDisplayName(account)} (@${account.acct})`,
})
}
</script>

View File

@ -7,16 +7,13 @@ const { t } = useI18n()
const params = useRoute().params
const handle = $(computedEager(() => params.account as string))
const { data: account } = await useAsyncData(`account:${handle}`, async () => (
window.history.state?.account as Account | undefined)
?? await fetchAccountByHandle(handle),
)
const account = await fetchAccountByHandle(handle)
const paginator = useMasto().accounts.iterateStatuses(account.value!.id, { excludeReplies: false })
const paginator = useMasto().accounts.iterateStatuses(account.id, { excludeReplies: false })
if (account) {
useHeadFixed({
title: () => `${t('tab.posts_with_replies')} | ${getDisplayName(account.value!)} (@${account.value!.acct})`,
title: () => `${t('tab.posts_with_replies')} | ${getDisplayName(account)} (@${account.acct})`,
})
}
</script>