Skip to content

Commit

Permalink
fix(home): hide friend section if nothing
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <tukon479@gmail.com>
  • Loading branch information
Innei committed Feb 14, 2023
1 parent 09c1e09 commit 0acdcc6
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/components/in-page/Home/SectionNews/friend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import useSWR from 'swr'
import type { LinkModel } from '@mx-space/api-client'
import { LinkState, LinkType } from '@mx-space/api-client'
import { Avatar } from '@mx-space/kami-design/components/Avatar'
import { PhUsersDuotone } from '@mx-space/kami-design/components/Icons'

import { apiClient } from '~/utils/client'

import styles from './index.module.css'
import { SectionWrap } from './section'

export const FriendItem: FC<LinkModel> = memo((props) => {
return (
Expand Down Expand Up @@ -46,11 +48,22 @@ export const FriendsSection: FC = memo(() => {
mutate()
}, [])

if (!friends || !friends.length) {
return null
}

return (
<div className={styles['friends-wrap']}>
{friends?.map((item) => {
return <FriendItem {...item} key={item.id} />
})}
</div>
<SectionWrap
title="朋友们"
moreUrl="friends"
icon={<PhUsersDuotone />}
className={'w-full'}
>
<div className={styles['friends-wrap']}>
{friends?.map((item) => {
return <FriendItem {...item} key={item.id} />
})}
</div>
</SectionWrap>
)
})

0 comments on commit 0acdcc6

Please sign in to comment.