Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/components/PagedContents/PostsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import EmptyLabel from '@/components/EmptyLabel'
const PostsList = ({ props }) => {
const {
entries,
cover,
active,
curView,
community,
Expand All @@ -32,7 +31,6 @@ const PostsList = ({ props }) => {
<PostItem
key={entry.id}
entry={entry}
cover={cover}
active={active}
community={community}
accountInfo={accountInfo}
Expand Down
4 changes: 0 additions & 4 deletions src/components/PagedContents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const log = buildLog('c:PagedContents:index')

const PagedContents = ({
thread,
cover,
active,
data: { entries, pageNumber, pageSize, totalCount },
curView,
Expand All @@ -41,7 +40,6 @@ const PagedContents = ({
<>
<ContentList
thread={thread}
cover={cover}
active={active}
entries={entries}
curView={curView}
Expand All @@ -66,7 +64,6 @@ const PagedContents = ({

PagedContents.propTypes = {
thread: T.oneOf([THREAD.POST, THREAD.JOB, THREAD.REPO]),
cover: T.oneOf(['avatar', 'source']),
active: T.object,
data: T.shape({
entries: T.array.isRequired,
Expand Down Expand Up @@ -99,7 +96,6 @@ PagedContents.propTypes = {

PagedContents.defaultProps = {
thread: THREAD.POST,
cover: 'avatar',
active: {},
curView: TYPE.LOADING,
emptyPrefix: '',
Expand Down
13 changes: 2 additions & 11 deletions src/components/PostItem/DigestView/DesktopView/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import React, { FC } from 'react'

import type { TPost, TUser, TAccount } from '@/spec'
import { ICON_BASE } from '@/config'

import TheAvatar from '@/components/TheAvatar'

import Header from './Header'
import Body from './Body'

import { Avatar, Main } from '../../styles/digest_view/index'
import { Main } from '../../styles/digest_view/index'

type TProps = {
active?: TPost | null
entry: TPost
cover: 'avatar' | 'source'

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

const DigestView: FC<TProps> = ({
entry,
cover,
onPreview,
onUserSelect,
onAuthorSelect,
}) => {
return (
<React.Fragment>
{cover === 'avatar' ? (
<TheAvatar user={entry.author} onSelect={onAuthorSelect} />
) : (
<Avatar
src={entry.linkIcon || `${ICON_BASE}/radar_source/default_radar.svg`}
/>
)}
<TheAvatar user={entry.author} onSelect={onAuthorSelect} />
<Main>
<Header item={entry} onUserSelect={onUserSelect} />
<Body item={entry} onPreview={onPreview} />
Expand Down
18 changes: 5 additions & 13 deletions src/components/PostItem/DigestView/MobileView/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { FC } from 'react'
import TimeAgo from 'timeago-react'

import type { TPost, TAccount } from '@/spec'
import { ICON_BASE } from '@/config'

import InlineTags from '@/components/InlineTags'
import DotDivider from '@/components/DotDivider'
Expand All @@ -19,26 +18,19 @@ import {

type TProps = {
item: TPost
cover: 'avatar' | 'source'
onAuthorSelect?: (obj: TAccount) => void
}

const Header: FC<TProps> = ({ cover, item, onAuthorSelect }) => {
const Header: FC<TProps> = ({ item, onAuthorSelect }) => {
return (
<Wrapper>
<AuthorInfo>
{cover === 'avatar' ? (
<AvatarWrapper onClick={() => onAuthorSelect(item.author)}>
<Avatar
src={item.author.avatar}
fallback={<ImgFallback user={item.author} size={16} right={6} />}
/>
</AvatarWrapper>
) : (
<AvatarWrapper onClick={() => onAuthorSelect(item.author)}>
<Avatar
src={item.linkIcon || `${ICON_BASE}/radar_source/default_radar.svg`}
src={item.author.avatar}
fallback={<ImgFallback user={item.author} size={16} right={6} />}
/>
)}
</AvatarWrapper>
<div>{item.author.nickname}</div>
<DotDivider radius={3} space={6} />
<TimeStamp>
Expand Down
10 changes: 2 additions & 8 deletions src/components/PostItem/DigestView/MobileView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,16 @@ import { Wrapper } from '../../styles/mobile_view/index'

type TProps = {
entry: TPost
cover: 'avatar' | 'source'
community: string

onPreview?: (obj: TPost) => void
onAuthorSelect?: (obj: TAccount) => void
}

const MobileView: FC<TProps> = ({
entry,
cover,
onPreview,
onAuthorSelect,
}) => {
const MobileView: FC<TProps> = ({ entry, onPreview, onAuthorSelect }) => {
return (
<Wrapper>
<Header item={entry} cover={cover} onAuthorSelect={onAuthorSelect} />
<Header item={entry} onAuthorSelect={onAuthorSelect} />
<Body item={entry} onPreview={onPreview} />
<Footer item={entry} />
</Wrapper>
Expand Down
3 changes: 0 additions & 3 deletions src/components/PostItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const log = buildLog('c:PostItem:index')
type TProps = {
active?: TPost | null
entry: TPost
cover: 'avatar' | 'source'
community: string
accountInfo: TAccount

Expand All @@ -38,7 +37,6 @@ const PostItem: FC<TProps> = ({
onUserSelect = log,
onAuthorSelect = log,
active = null,
cover = 'avatar',
community = HCN,
accountInfo = {
isLogin: false,
Expand Down Expand Up @@ -66,7 +64,6 @@ const PostItem: FC<TProps> = ({
{contentsLayout === C11N.DIGEST ? (
<DigestView
entry={entry}
cover={cover}
community={community}
onPreview={onPreview}
onUserSelect={onUserSelect}
Expand Down
2 changes: 1 addition & 1 deletion src/containers/digest/CommunityDigest/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const tabOnChange = (activeThread) => {
store.markRoute({ subPath })
store.setViewing({ activeThread })

send(EVENT.THREAD_CHANGE, { data: { activeThread, topic: subPath } })
send(EVENT.THREAD_CHANGE, { data: { activeThread } })
}

export const onShowEditorList = () => {
Expand Down
2 changes: 0 additions & 2 deletions src/containers/editor/PostEditor/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export const onPublish = () => {
if (!store.validator('general')) return false
if (!specCheck()) return false

const { subPath: topic } = store.curRoute
const { body } = store.editData
const { isEdit } = store
publishing()
Expand All @@ -80,7 +79,6 @@ export const onPublish = () => {
communityId: store.viewing.community.id,
digest,
length,
topic,
mentionUsers: map((user) => ({ id: user.id }), store.referUsersData),
}
if (!isEmpty(store.labelsData.tags)) {
Expand Down
2 changes: 0 additions & 2 deletions src/containers/editor/PostEditor/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const createPost = gql`
$communityId: ID!
$tags: [Ids]
$mentionUsers: [Ids]
$topic: String
) {
createPost(
title: $title
Expand All @@ -24,7 +23,6 @@ const createPost = gql`
communityId: $communityId
tags: $tags
mentionUsers: $mentionUsers
topic: $topic
) {
id
title
Expand Down
3 changes: 0 additions & 3 deletions src/containers/thread/PostsThread/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ const PostsThreadContainer = ({ postsThread: store }) => {

const { subPath } = curRoute
const { totalCount } = pagedPostsData
const topic = subPath

return (
<Wrapper>
Expand Down Expand Up @@ -134,7 +133,6 @@ const PostsThreadContainer = ({ postsThread: store }) => {
<FaqPeekList active={faqActive} />
<PagedContents
data={pagedPostsData}
cover={curThread === THREAD.RADAR ? 'source' : 'avatar'}
community={curCommunity.raw}
thread={THREAD.POST}
curView={curView}
Expand Down Expand Up @@ -184,7 +182,6 @@ const PostsThreadContainer = ({ postsThread: store }) => {
</BadgeWrapper>
<TagsBar
thread={THREAD.POST}
topic={topic}
onSelect={onTagSelect}
active={activeTagData}
/>
Expand Down
7 changes: 0 additions & 7 deletions src/containers/thread/PostsThread/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ export const outAnchor = () => {

export const loadPosts = (page = 1) => {
const { curCommunity } = store
const { subPath: topic } = store.curRoute

// display same-city list instead
if (curCommunity.raw === ROUTE.HOME && topic === THREAD.CITY) return false

const userHasLogin = store.isLogin

Expand All @@ -67,9 +63,6 @@ export const loadPosts = (page = 1) => {
userHasLogin,
}

if (curCommunity.raw === ROUTE.HOME) {
args.filter = merge(args.filter, { topic })
}
args.filter = pickBy(notEmpty, args.filter)

store.mark({ curView: TYPE.LOADING })
Expand Down
13 changes: 3 additions & 10 deletions src/containers/unit/ArticleBodyHeader/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ export const onPin = (thread) => {
return sr71$.mutate(S.pinRepo, args)

default: {
const { subPath: topic } = store.curRoute
return sr71$.mutate(S.pinPost, merge(args, { topic }))
return sr71$.mutate(S.pinPost, args)
}
}
}
Expand All @@ -71,24 +70,18 @@ export const onUndoPin = (thread) => {
return sr71$.mutate(S.undoPinRepo, args)

default: {
const { subPath: topic } = store.curRoute
return sr71$.mutate(S.undoPinPost, merge(args, { topic }))
return sr71$.mutate(S.undoPinPost, args)
}
}
}

const getRefinedArgs = (thread) => {
let args = {
const args = {
id: store.viewingData.id,
communityId: store.curCommunity.id,
thread: toUpper(thread),
}

if (thread === THREAD.POST) {
const { subPath: topic } = store.curRoute
args = merge(args, { topic })
}

return args
}

Expand Down
26 changes: 8 additions & 18 deletions src/containers/unit/ArticleBodyHeader/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { P } from '@/schemas'

// post
const pinPost = gql`
mutation($id: ID!, $communityId: ID!, $topic: String) {
pinPost(id: $id, communityId: $communityId, topic: $topic) {
mutation($id: ID!, $communityId: ID!) {
pinPost(id: $id, communityId: $communityId) {
id
}
}
`
const undoPinPost = gql`
mutation($id: ID!, $communityId: ID!, $topic: String) {
undoPinPost(id: $id, communityId: $communityId, topic: $topic) {
mutation($id: ID!, $communityId: ID!) {
undoPinPost(id: $id, communityId: $communityId) {
id
}
}
Expand Down Expand Up @@ -71,26 +71,16 @@ const deleteRepo = gql`

// refined tag
const setRefinedTag = gql`
mutation($communityId: ID!, $thread: CmsThread, $topic: String, $id: ID!) {
setRefinedTag(
communityId: $communityId
thread: $thread
topic: $topic
id: $id
) {
mutation($communityId: ID!, $thread: CmsThread, $id: ID!) {
setRefinedTag(communityId: $communityId, thread: $thread, id: $id) {
id
title
}
}
`
const unsetRefinedTag = gql`
mutation($communityId: ID!, $thread: CmsThread, $topic: String, $id: ID!) {
unsetRefinedTag(
communityId: $communityId
thread: $thread
topic: $topic
id: $id
) {
mutation($communityId: ID!, $thread: CmsThread, $id: ID!) {
unsetRefinedTag(communityId: $communityId, thread: $thread, id: $id) {
id
title
}
Expand Down
2 changes: 1 addition & 1 deletion src/containers/unit/Header/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const onThreadChange = (activeThread: TThread): void => {

store.markRoute({ subPath })
store.setViewing({ activeThread })
send(EVENT.THREAD_CHANGE, { data: { activeThread, topic: subPath } })
send(EVENT.THREAD_CHANGE, { data: { activeThread } })
}

export const onLogin = (): void => send(EVENT.LOGIN_PANEL)
Expand Down
2 changes: 1 addition & 1 deletion src/containers/unit/ModeLine/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const tabOnChange = (activeThread) => {
store.markRoute({ subPath })
store.setViewing({ activeThread })

send(EVENT.THREAD_CHANGE, { data: { activeThread, topic: subPath } })
send(EVENT.THREAD_CHANGE, { data: { activeThread } })
}

export const openMenu = (activeMenu) => {
Expand Down
Loading