Fix wrong empty state for liked by (#5343)

zio/dev^2
dan 2024-09-15 20:14:46 +01:00 committed by GitHub
parent 55da2704d8
commit d6c11a7231
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 26 additions and 1 deletions

View File

@ -75,6 +75,7 @@ export function LikedByList({uri}: {uri: string}) {
isLoading={isUriLoading || isLikedByLoading} isLoading={isUriLoading || isLikedByLoading}
isError={isError} isError={isError}
emptyType="results" emptyType="results"
emptyTitle={_(msg`No likes yet`)}
emptyMessage={_( emptyMessage={_(
msg`Nobody has liked this yet. Maybe you should be the first!`, msg`Nobody has liked this yet. Maybe you should be the first!`,
)} )}

View File

@ -1,5 +1,7 @@
import React, {useCallback, useMemo, useState} from 'react' import React, {useCallback, useMemo, useState} from 'react'
import {AppBskyFeedGetLikes as GetLikes} from '@atproto/api' import {AppBskyFeedGetLikes as GetLikes} from '@atproto/api'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {cleanError} from '#/lib/strings/errors' import {cleanError} from '#/lib/strings/errors'
import {logger} from '#/logger' import {logger} from '#/logger'
@ -26,6 +28,7 @@ function keyExtractor(item: GetLikes.Like) {
} }
export function PostLikedBy({uri}: {uri: string}) { export function PostLikedBy({uri}: {uri: string}) {
const {_} = useLingui()
const initialNumToRender = useInitialNumToRender() const initialNumToRender = useInitialNumToRender()
const [isPTRing, setIsPTRing] = useState(false) const [isPTRing, setIsPTRing] = useState(false)
@ -78,6 +81,12 @@ export function PostLikedBy({uri}: {uri: string}) {
<ListMaybePlaceholder <ListMaybePlaceholder
isLoading={isLoadingUri || isLoadingLikes} isLoading={isLoadingUri || isLoadingLikes}
isError={isError} isError={isError}
emptyType="results"
emptyTitle={_(msg`No likes yet`)}
emptyMessage={_(
msg`Nobody has liked this yet. Maybe you should be the first!`,
)}
errorMessage={cleanError(resolveError || error)}
sideBorders={false} sideBorders={false}
/> />
) )

View File

@ -97,11 +97,17 @@ export function PostQuotes({uri}: {uri: string}) {
} }
}, [isFetchingNextPage, hasNextPage, isError, fetchNextPage]) }, [isFetchingNextPage, hasNextPage, isError, fetchNextPage])
if (isLoadingUri || isLoadingQuotes || isError) { if (quotes.length < 1) {
return ( return (
<ListMaybePlaceholder <ListMaybePlaceholder
isLoading={isLoadingUri || isLoadingQuotes} isLoading={isLoadingUri || isLoadingQuotes}
isError={isError} isError={isError}
emptyType="results"
emptyTitle={_(msg`No quotes yet`)}
emptyMessage={_(
msg`Nobody has quoted this yet. Maybe you should be the first!`,
)}
errorMessage={cleanError(resolveError || error)}
sideBorders={false} sideBorders={false}
/> />
) )

View File

@ -1,5 +1,7 @@
import React, {useCallback, useMemo, useState} from 'react' import React, {useCallback, useMemo, useState} from 'react'
import {AppBskyActorDefs as ActorDefs} from '@atproto/api' import {AppBskyActorDefs as ActorDefs} from '@atproto/api'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {cleanError} from '#/lib/strings/errors' import {cleanError} from '#/lib/strings/errors'
import {logger} from '#/logger' import {logger} from '#/logger'
@ -19,6 +21,7 @@ function keyExtractor(item: ActorDefs.ProfileViewBasic) {
} }
export function PostRepostedBy({uri}: {uri: string}) { export function PostRepostedBy({uri}: {uri: string}) {
const {_} = useLingui()
const initialNumToRender = useInitialNumToRender() const initialNumToRender = useInitialNumToRender()
const [isPTRing, setIsPTRing] = useState(false) const [isPTRing, setIsPTRing] = useState(false)
@ -71,6 +74,12 @@ export function PostRepostedBy({uri}: {uri: string}) {
<ListMaybePlaceholder <ListMaybePlaceholder
isLoading={isLoadingUri || isLoadingRepostedBy} isLoading={isLoadingUri || isLoadingRepostedBy}
isError={isError} isError={isError}
emptyType="results"
emptyTitle={_(msg`No reposts yet`)}
emptyMessage={_(
msg`Nobody has reposted this yet. Maybe you should be the first!`,
)}
errorMessage={cleanError(resolveError || error)}
sideBorders={false} sideBorders={false}
/> />
) )