From 72ce43dde9f792d6b9963187dc9cdf5ed86c3bae Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 2 Jan 2023 01:00:13 +0100 Subject: [PATCH] fix: remove history state fallback + asyncdata (#687) --- pages/[[server]]/@[account]/[status].vue | 2 +- pages/[[server]]/@[account]/index/index.vue | 9 +++------ pages/[[server]]/@[account]/index/media.vue | 9 +++------ pages/[[server]]/@[account]/index/with_replies.vue | 9 +++------ 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/pages/[[server]]/@[account]/[status].vue b/pages/[[server]]/@[account]/[status].vue index 80ea2949..a2887195 100644 --- a/pages/[[server]]/@[account]/[status].vue +++ b/pages/[[server]]/@[account]/[status].vue @@ -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() diff --git a/pages/[[server]]/@[account]/index/index.vue b/pages/[[server]]/@[account]/index/index.vue index 6ff53fa6..e01254f5 100644 --- a/pages/[[server]]/@[account]/index/index.vue +++ b/pages/[[server]]/@[account]/index/index.vue @@ -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})`, }) } diff --git a/pages/[[server]]/@[account]/index/media.vue b/pages/[[server]]/@[account]/index/media.vue index daf25590..16ec2024 100644 --- a/pages/[[server]]/@[account]/index/media.vue +++ b/pages/[[server]]/@[account]/index/media.vue @@ -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})`, }) } diff --git a/pages/[[server]]/@[account]/index/with_replies.vue b/pages/[[server]]/@[account]/index/with_replies.vue index 48154054..c0f4cac6 100644 --- a/pages/[[server]]/@[account]/index/with_replies.vue +++ b/pages/[[server]]/@[account]/index/with_replies.vue @@ -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})`, }) }