Skip to content

Commit 0acdcc6

Browse files
committed
fix(home): hide friend section if nothing
Signed-off-by: Innei <tukon479@gmail.com>
1 parent 09c1e09 commit 0acdcc6

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/components/in-page/Home/SectionNews/friend.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import useSWR from 'swr'
66
import type { LinkModel } from '@mx-space/api-client'
77
import { LinkState, LinkType } from '@mx-space/api-client'
88
import { Avatar } from '@mx-space/kami-design/components/Avatar'
9+
import { PhUsersDuotone } from '@mx-space/kami-design/components/Icons'
910

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

1213
import styles from './index.module.css'
14+
import { SectionWrap } from './section'
1315

1416
export const FriendItem: FC<LinkModel> = memo((props) => {
1517
return (
@@ -46,11 +48,22 @@ export const FriendsSection: FC = memo(() => {
4648
mutate()
4749
}, [])
4850

51+
if (!friends || !friends.length) {
52+
return null
53+
}
54+
4955
return (
50-
<div className={styles['friends-wrap']}>
51-
{friends?.map((item) => {
52-
return <FriendItem {...item} key={item.id} />
53-
})}
54-
</div>
56+
<SectionWrap
57+
title="朋友们"
58+
moreUrl="friends"
59+
icon={<PhUsersDuotone />}
60+
className={'w-full'}
61+
>
62+
<div className={styles['friends-wrap']}>
63+
{friends?.map((item) => {
64+
return <FriendItem {...item} key={item.id} />
65+
})}
66+
</div>
67+
</SectionWrap>
5568
)
5669
})

0 commit comments

Comments
 (0)