Fix sloppy filter(Boolean) types (#4830)
* Fix sloppy filter(Boolean) in threadgate * Fix sloppy filter(Boolean) in Explore * Fix sloppy filter(Boolean) in post-feed * Harden FeedPostSliceItem.reason type def * Harden parentAuthor types * Fix lying component types, handle blocks
This commit is contained in:
parent
fac1af43b0
commit
4291711f1d
4 changed files with 88 additions and 56 deletions
|
@ -75,17 +75,17 @@ function SuggestedItemsHeader({
|
|||
)
|
||||
}
|
||||
|
||||
type LoadMoreItems =
|
||||
type LoadMoreItem =
|
||||
| {
|
||||
type: 'profile'
|
||||
key: string
|
||||
avatar: string
|
||||
avatar: string | undefined
|
||||
moderation: ModerationDecision
|
||||
}
|
||||
| {
|
||||
type: 'feed'
|
||||
key: string
|
||||
avatar: string
|
||||
avatar: string | undefined
|
||||
moderation: undefined
|
||||
}
|
||||
|
||||
|
@ -98,27 +98,28 @@ function LoadMore({
|
|||
}) {
|
||||
const t = useTheme()
|
||||
const {_} = useLingui()
|
||||
const items = React.useMemo(() => {
|
||||
const items: LoadMoreItem[] = React.useMemo(() => {
|
||||
return item.items
|
||||
.map(_item => {
|
||||
let loadMoreItem: LoadMoreItem | undefined
|
||||
if (_item.type === 'profile') {
|
||||
return {
|
||||
loadMoreItem = {
|
||||
type: 'profile',
|
||||
key: _item.profile.did,
|
||||
avatar: _item.profile.avatar,
|
||||
moderation: moderateProfile(_item.profile, moderationOpts!),
|
||||
}
|
||||
} else if (_item.type === 'feed') {
|
||||
return {
|
||||
loadMoreItem = {
|
||||
type: 'feed',
|
||||
key: _item.feed.uri,
|
||||
avatar: _item.feed.avatar,
|
||||
moderation: undefined,
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
return loadMoreItem
|
||||
})
|
||||
.filter(Boolean) as LoadMoreItems[]
|
||||
.filter(<T,>(n?: T): n is T => Boolean(n))
|
||||
}, [item.items, moderationOpts])
|
||||
|
||||
if (items.length === 0) return null
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue