mirror of
https://github.com/elk-zone/elk
synced 2024-11-27 22:38:11 +09:00
fix: avoid fetching null account id
This commit is contained in:
parent
b078e456cc
commit
abbd026c1d
@ -5,7 +5,7 @@ const { status } = defineProps<{
|
|||||||
status: Status
|
status: Status
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const account = useAccountById(status.inReplyToAccountId!)
|
const account = useAccountById(status.inReplyToAccountId)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -28,7 +28,10 @@ export function fetchStatus(id: string, force = false): Promise<Status> {
|
|||||||
return promise
|
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 key = `account:${id}`
|
||||||
const cached = cache.get(key)
|
const cached = cache.get(key)
|
||||||
if (cached)
|
if (cached)
|
||||||
@ -63,7 +66,7 @@ export function useAccountByHandle(acct: string) {
|
|||||||
return useAsyncState(() => fetchAccountByHandle(acct), null).state
|
return useAsyncState(() => fetchAccountByHandle(acct), null).state
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useAccountById(id: string) {
|
export function useAccountById(id?: string | null) {
|
||||||
return useAsyncState(() => fetchAccountById(id), null).state
|
return useAsyncState(() => fetchAccountById(id), null).state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user