Skip to content

Commit

Permalink
fix: remove history state fallback + asyncdata (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Jan 2, 2023
1 parent 451c4a0 commit 72ce43d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pages/[[server]]/@[account]/[status].vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 3 additions & 6 deletions pages/[[server]]/@[account]/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
9 changes: 3 additions & 6 deletions pages/[[server]]/@[account]/index/media.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
9 changes: 3 additions & 6 deletions pages/[[server]]/@[account]/index/with_replies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 72ce43d

Please sign in to comment.