feat: preserving state between route changes (#132)
This commit is contained in:
parent
d967520005
commit
6414f2a4e2
9 changed files with 63 additions and 10 deletions
|
@ -1,14 +1,20 @@
|
|||
<script setup lang="ts">
|
||||
const params = useRoute().params
|
||||
const accountName = $computed(() => toShortHandle(params.account as string))
|
||||
const accountName = $(computedEager(() => toShortHandle(params.account as string)))
|
||||
|
||||
const account = await fetchAccountByName(accountName).catch(() => null)
|
||||
const { data: account, refresh } = $(await useAsyncData(() => fetchAccountByName(accountName).catch(() => null)))
|
||||
|
||||
if (account) {
|
||||
useHead({
|
||||
title: () => `${getDisplayName(account)} (@${account.acct})`,
|
||||
})
|
||||
}
|
||||
|
||||
onReactivated(() => {
|
||||
// Silently update data when reentering the page
|
||||
// The user will see the previous content first, and any changes will be updated to the UI when the request is completed
|
||||
refresh()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue