Skip to content

Commit

Permalink
add default empty state text (#7212)
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzius authored Dec 20, 2024
1 parent aeb78da commit 8f7a6e5
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/view/com/lists/MyLists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
ViewStyle,
} from 'react-native'
import {AppBskyGraphDefs as GraphDefs} from '@atproto/api'
import {Trans} from '@lingui/macro'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'

import {usePalette} from '#/lib/hooks/usePalette'
import {cleanError} from '#/lib/strings/errors'
Expand Down Expand Up @@ -42,6 +43,7 @@ export function MyLists({
}) {
const pal = usePalette('default')
const t = useTheme()
const {_} = useLingui()
const moderationOpts = useModerationOpts()
const [isPTRing, setIsPTRing] = React.useState(false)
const {data, isFetching, isFetched, isError, error, refetch} =
Expand All @@ -63,6 +65,23 @@ export function MyLists({
return items
}, [isError, isEmpty, isFetched, isFetching, moderationOpts, data])

let emptyText
switch (filter) {
case 'curate':
emptyText = _(
msg`Public, sharable lists which can be used to drive feeds.`,
)
break
case 'mod':
emptyText = _(
msg`Public, sharable lists of users to mute or block in bulk.`,
)
break
default:
emptyText = _(msg`You have no lists.`)
break
}

// events
// =

Expand Down Expand Up @@ -108,16 +127,7 @@ export function MyLists({
maxWidth: 200,
},
]}>
{filter === 'curate' && (
<Trans>
Public, sharable lists which can be used to drive feeds.
</Trans>
)}
{filter === 'mod' && (
<Trans>
Public, sharable lists of users to mute or block in bulk.
</Trans>
)}
{emptyText}
</Text>
</View>
)
Expand Down Expand Up @@ -149,7 +159,7 @@ export function MyLists({
</View>
)
},
[t, renderItem, error, onRefresh, filter],
[t, renderItem, error, onRefresh, emptyText],
)

if (inline) {
Expand Down

0 comments on commit 8f7a6e5

Please sign in to comment.