fix: avoid fetching null account id

zio/stable
Daniel Roe 2022-12-06 23:38:00 +00:00
parent b078e456cc
commit abbd026c1d
No known key found for this signature in database
GPG Key ID: 22D5008E4F5D9B55
2 changed files with 6 additions and 3 deletions

View File

@ -5,7 +5,7 @@ const { status } = defineProps<{
status: Status
}>()
const account = useAccountById(status.inReplyToAccountId!)
const account = useAccountById(status.inReplyToAccountId)
</script>
<template>

View File

@ -28,7 +28,10 @@ export function fetchStatus(id: string, force = false): Promise<Status> {
return promise
}
export function fetchAccountById(id: string): Promise<Account> {
export function fetchAccountById(id?: string | null): Promise<Account | null> {
if (!id)
return Promise.resolve(null)
const key = `account:${id}`
const cached = cache.get(key)
if (cached)
@ -63,7 +66,7 @@ export function useAccountByHandle(acct: string) {
return useAsyncState(() => fetchAccountByHandle(acct), null).state
}
export function useAccountById(id: string) {
export function useAccountById(id?: string | null) {
return useAsyncState(() => fetchAccountById(id), null).state
}