Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 78edd2b

Browse files
authored
refactor(psots): remove topic concept (#1085)
* refactor(psots): remove topic concept * refactor(psots): remove cover concept on PostItem * refactor(psots): remove cover concept on PostItem
1 parent 7cfc87b commit 78edd2b

File tree

26 files changed

+43
-155
lines changed

26 files changed

+43
-155
lines changed

src/components/PagedContents/PostsList.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import EmptyLabel from '@/components/EmptyLabel'
1212
const PostsList = ({ props }) => {
1313
const {
1414
entries,
15-
cover,
1615
active,
1716
curView,
1817
community,
@@ -32,7 +31,6 @@ const PostsList = ({ props }) => {
3231
<PostItem
3332
key={entry.id}
3433
entry={entry}
35-
cover={cover}
3634
active={active}
3735
community={community}
3836
accountInfo={accountInfo}

src/components/PagedContents/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const log = buildLog('c:PagedContents:index')
1919

2020
const PagedContents = ({
2121
thread,
22-
cover,
2322
active,
2423
data: { entries, pageNumber, pageSize, totalCount },
2524
curView,
@@ -41,7 +40,6 @@ const PagedContents = ({
4140
<>
4241
<ContentList
4342
thread={thread}
44-
cover={cover}
4543
active={active}
4644
entries={entries}
4745
curView={curView}
@@ -66,7 +64,6 @@ const PagedContents = ({
6664

6765
PagedContents.propTypes = {
6866
thread: T.oneOf([THREAD.POST, THREAD.JOB, THREAD.REPO]),
69-
cover: T.oneOf(['avatar', 'source']),
7067
active: T.object,
7168
data: T.shape({
7269
entries: T.array.isRequired,
@@ -99,7 +96,6 @@ PagedContents.propTypes = {
9996

10097
PagedContents.defaultProps = {
10198
thread: THREAD.POST,
102-
cover: 'avatar',
10399
active: {},
104100
curView: TYPE.LOADING,
105101
emptyPrefix: '',

src/components/PostItem/DigestView/DesktopView/index.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
import React, { FC } from 'react'
22

33
import type { TPost, TUser, TAccount } from '@/spec'
4-
import { ICON_BASE } from '@/config'
54

65
import TheAvatar from '@/components/TheAvatar'
76

87
import Header from './Header'
98
import Body from './Body'
109

11-
import { Avatar, Main } from '../../styles/digest_view/index'
10+
import { Main } from '../../styles/digest_view/index'
1211

1312
type TProps = {
1413
active?: TPost | null
1514
entry: TPost
16-
cover: 'avatar' | 'source'
1715

1816
onPreview?: (obj: TPost) => void
1917
onUserSelect?: (obj: TUser) => void
@@ -22,20 +20,13 @@ type TProps = {
2220

2321
const DigestView: FC<TProps> = ({
2422
entry,
25-
cover,
2623
onPreview,
2724
onUserSelect,
2825
onAuthorSelect,
2926
}) => {
3027
return (
3128
<React.Fragment>
32-
{cover === 'avatar' ? (
33-
<TheAvatar user={entry.author} onSelect={onAuthorSelect} />
34-
) : (
35-
<Avatar
36-
src={entry.linkIcon || `${ICON_BASE}/radar_source/default_radar.svg`}
37-
/>
38-
)}
29+
<TheAvatar user={entry.author} onSelect={onAuthorSelect} />
3930
<Main>
4031
<Header item={entry} onUserSelect={onUserSelect} />
4132
<Body item={entry} onPreview={onPreview} />

src/components/PostItem/DigestView/MobileView/Header.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { FC } from 'react'
22
import TimeAgo from 'timeago-react'
33

44
import type { TPost, TAccount } from '@/spec'
5-
import { ICON_BASE } from '@/config'
65

76
import InlineTags from '@/components/InlineTags'
87
import DotDivider from '@/components/DotDivider'
@@ -19,26 +18,19 @@ import {
1918

2019
type TProps = {
2120
item: TPost
22-
cover: 'avatar' | 'source'
2321
onAuthorSelect?: (obj: TAccount) => void
2422
}
2523

26-
const Header: FC<TProps> = ({ cover, item, onAuthorSelect }) => {
24+
const Header: FC<TProps> = ({ item, onAuthorSelect }) => {
2725
return (
2826
<Wrapper>
2927
<AuthorInfo>
30-
{cover === 'avatar' ? (
31-
<AvatarWrapper onClick={() => onAuthorSelect(item.author)}>
32-
<Avatar
33-
src={item.author.avatar}
34-
fallback={<ImgFallback user={item.author} size={16} right={6} />}
35-
/>
36-
</AvatarWrapper>
37-
) : (
28+
<AvatarWrapper onClick={() => onAuthorSelect(item.author)}>
3829
<Avatar
39-
src={item.linkIcon || `${ICON_BASE}/radar_source/default_radar.svg`}
30+
src={item.author.avatar}
31+
fallback={<ImgFallback user={item.author} size={16} right={6} />}
4032
/>
41-
)}
33+
</AvatarWrapper>
4234
<div>{item.author.nickname}</div>
4335
<DotDivider radius={3} space={6} />
4436
<TimeStamp>

src/components/PostItem/DigestView/MobileView/index.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,16 @@ import { Wrapper } from '../../styles/mobile_view/index'
1010

1111
type TProps = {
1212
entry: TPost
13-
cover: 'avatar' | 'source'
1413
community: string
1514

1615
onPreview?: (obj: TPost) => void
1716
onAuthorSelect?: (obj: TAccount) => void
1817
}
1918

20-
const MobileView: FC<TProps> = ({
21-
entry,
22-
cover,
23-
onPreview,
24-
onAuthorSelect,
25-
}) => {
19+
const MobileView: FC<TProps> = ({ entry, onPreview, onAuthorSelect }) => {
2620
return (
2721
<Wrapper>
28-
<Header item={entry} cover={cover} onAuthorSelect={onAuthorSelect} />
22+
<Header item={entry} onAuthorSelect={onAuthorSelect} />
2923
<Body item={entry} onPreview={onPreview} />
3024
<Footer item={entry} />
3125
</Wrapper>

src/components/PostItem/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const log = buildLog('c:PostItem:index')
2323
type TProps = {
2424
active?: TPost | null
2525
entry: TPost
26-
cover: 'avatar' | 'source'
2726
community: string
2827
accountInfo: TAccount
2928

@@ -38,7 +37,6 @@ const PostItem: FC<TProps> = ({
3837
onUserSelect = log,
3938
onAuthorSelect = log,
4039
active = null,
41-
cover = 'avatar',
4240
community = HCN,
4341
accountInfo = {
4442
isLogin: false,
@@ -66,7 +64,6 @@ const PostItem: FC<TProps> = ({
6664
{contentsLayout === C11N.DIGEST ? (
6765
<DigestView
6866
entry={entry}
69-
cover={cover}
7067
community={community}
7168
onPreview={onPreview}
7269
onUserSelect={onUserSelect}

src/containers/digest/CommunityDigest/logic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const tabOnChange = (activeThread) => {
3838
store.markRoute({ subPath })
3939
store.setViewing({ activeThread })
4040

41-
send(EVENT.THREAD_CHANGE, { data: { activeThread, topic: subPath } })
41+
send(EVENT.THREAD_CHANGE, { data: { activeThread } })
4242
}
4343

4444
export const onShowEditorList = () => {

src/containers/editor/PostEditor/logic.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export const onPublish = () => {
6767
if (!store.validator('general')) return false
6868
if (!specCheck()) return false
6969

70-
const { subPath: topic } = store.curRoute
7170
const { body } = store.editData
7271
const { isEdit } = store
7372
publishing()
@@ -80,7 +79,6 @@ export const onPublish = () => {
8079
communityId: store.viewing.community.id,
8180
digest,
8281
length,
83-
topic,
8482
mentionUsers: map((user) => ({ id: user.id }), store.referUsersData),
8583
}
8684
if (!isEmpty(store.labelsData.tags)) {

src/containers/editor/PostEditor/schema.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const createPost = gql`
1212
$communityId: ID!
1313
$tags: [Ids]
1414
$mentionUsers: [Ids]
15-
$topic: String
1615
) {
1716
createPost(
1817
title: $title
@@ -24,7 +23,6 @@ const createPost = gql`
2423
communityId: $communityId
2524
tags: $tags
2625
mentionUsers: $mentionUsers
27-
topic: $topic
2826
) {
2927
id
3028
title

src/containers/thread/PostsThread/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ const PostsThreadContainer = ({ postsThread: store }) => {
103103

104104
const { subPath } = curRoute
105105
const { totalCount } = pagedPostsData
106-
const topic = subPath
107106

108107
return (
109108
<Wrapper>
@@ -134,7 +133,6 @@ const PostsThreadContainer = ({ postsThread: store }) => {
134133
<FaqPeekList active={faqActive} />
135134
<PagedContents
136135
data={pagedPostsData}
137-
cover={curThread === THREAD.RADAR ? 'source' : 'avatar'}
138136
community={curCommunity.raw}
139137
thread={THREAD.POST}
140138
curView={curView}
@@ -184,7 +182,6 @@ const PostsThreadContainer = ({ postsThread: store }) => {
184182
</BadgeWrapper>
185183
<TagsBar
186184
thread={THREAD.POST}
187-
topic={topic}
188185
onSelect={onTagSelect}
189186
active={activeTagData}
190187
/>

0 commit comments

Comments
 (0)