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

Commit f30ec85

Browse files
authored
refactor: article list/viewer upvote action (#1167)
* refactor(article-list): handle upvote action on post-list & re-org * refactor(article-viewer): re-org with real data * refactor(article-viewer): upvote, viewer workflow, re-org * refactor(utils): macros re-org & doc update * style(editor): editor delete action adjust * refactor(upvote): enhance latestUser in upvote actions * refactor(upvote): enhance latestUser in viewer * chore(clean-up): unused container & code
1 parent bfc9df7 commit f30ec85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+477
-1187
lines changed

package-lock.json

Lines changed: 19 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
},
4242
"dependencies": {
4343
"@babel/core": "^7.13.14",
44-
"@groupher/react-editor": "^1.1.25",
44+
"@groupher/react-editor": "^1.1.26",
4545
"@next/bundle-analyzer": "^9.4.4",
4646
"@sentry/browser": "5.17.0",
4747
"@sentry/node": "5.17.0",

src/components/ArticleCard/Footer.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { FC, memo } from 'react'
22
import TimeAgo from 'timeago-react'
33

4-
import type { TJob } from '@/spec'
4+
import type { TArticle } from '@/spec'
5+
import { upvoteOnArticleList } from '@/utils/helper'
56
import { ICON } from '@/config'
67
import Upvote from '@/components/Upvote'
78
import DotDivider from '@/components/DotDivider'
@@ -10,11 +11,18 @@ import IconText from '@/components/IconText'
1011
import { Wrapper, PublishWrapper, Bottom } from './styles/footer'
1112

1213
type TProps = {
13-
data: TJob
14+
data: TArticle
1415
}
1516

1617
const Footer: FC<TProps> = ({ data }) => {
17-
const { author, insertedAt, commentsCount, upvotesCount, meta } = data
18+
const {
19+
author,
20+
insertedAt,
21+
commentsCount,
22+
upvotesCount,
23+
viewerHasUpvoted,
24+
meta,
25+
} = data
1826

1927
return (
2028
<Wrapper>
@@ -23,7 +31,14 @@ const Footer: FC<TProps> = ({ data }) => {
2331
<TimeAgo datetime={insertedAt} locale="zh_CN" />
2432
</PublishWrapper>
2533
<Bottom>
26-
<Upvote count={upvotesCount} avatarList={meta.latestUpvotedUsers} />
34+
<Upvote
35+
count={upvotesCount}
36+
avatarList={meta.latestUpvotedUsers}
37+
viewerHasUpvoted={viewerHasUpvoted}
38+
onAction={(viewerHasUpvoted) =>
39+
upvoteOnArticleList(data, viewerHasUpvoted)
40+
}
41+
/>
2742
<IconText iconSrc={`${ICON}/article/comment.svg`} size="medium">
2843
{commentsCount}
2944
</IconText>

src/components/ArticleReadLabel/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const ArticleReadLabel: FC<TProps> = ({ entry, top = 24, left = -30 }) => {
2929
if (entry.pin) return null
3030
// return <ReadedLabel top={top} left={left} />
3131
if (!isLogin) return null
32-
if (markViewed && viewerHasViewed) {
32+
if (markViewed && !viewerHasViewed) {
3333
return <ReadedLabel top={top} left={left} />
3434
}
3535

src/components/AvatarsRow/RealAvatar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
type TProps = {
1919
user?: TUser
2020
size?: TAvatarSize
21-
scrollPosition?: any
2221
popCardPlacement?: 'top' | 'bottom'
2322
onUserSelect: (user: TUser) => void
2423
}
@@ -36,6 +35,7 @@ const RealAvatar: FC<TProps> = ({
3635
delay={0}
3736
contentHeight={getAvatarSize(size, 'number') as string}
3837
placement={popCardPlacement}
38+
interactive={false}
3939
>
4040
<InnerWrapper>
4141
<AvatarsImg

src/components/AvatarsRow/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const AvatarsRow: FC<TProps> = ({
9191
onTotalSelect = log,
9292
showMore = true,
9393
showTotalNumber = false,
94-
reverse = true,
94+
reverse = false,
9595
// see https://github.com/Aljullu/react-lazy-load-image-component/issues/42
9696
scrollPosition = null,
9797
popCardPlacement = 'bottom',
@@ -103,7 +103,7 @@ const AvatarsRow: FC<TProps> = ({
103103
const totalCount = total || users.length
104104

105105
users = filter(validUser, getUniqueArray(users, 'login'))
106-
const sortedUsers = reverse ? users : reverseFn(users)
106+
const sortedUsers = reverse ? reverseFn(users) : users
107107

108108
return (
109109
<Wrapper total={totalCount}>

src/components/AvatarsRow/styles/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const Wrapper = styled.ul<{ total: number }>`
1818
`
1919
export const AvatarsWrapper = styled.div`
2020
${css.flex()}
21-
flex-direction: row-reverse;
2221
`
2322
export const TotalOneOffset = styled.span`
2423
margin-right: 10px;

src/components/AvatarsRow/styles/real_avatar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const Wrapper = styled.li<TWrapper>`
1515
padding: 0px 0px 0px 0px;
1616
position: relative;
1717
width: ${({ size }) => getLiSize(size)};
18-
z-index: 2;
18+
/* z-index: 2; */
1919
2020
&:hover {
2121
z-index: 3;

src/components/Cards/UserCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const UserCard: FC<TProps> = ({ item }) => {
3131
<Avatar src={avatar} />
3232
<Info>
3333
<Title href={`user/${login}`}>
34-
<Nickname>{nickname}</Nickname>
34+
<Nickname>{cutRest(nickname, 12)}</Nickname>
3535
<Login>{login}</Login>
3636
</Title>
3737
{/* <ShortBio>{bio || '--'}</ShortBio> */}

src/components/EmotionSelector/SelectedEmotions/EmotionUnit.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,8 @@ const EmotionUnit: FC<TProps> = ({ item, onAction }) => {
3333

3434
return (
3535
<Tooltip
36-
content={
37-
<UsersPanel
38-
name={name}
39-
count={count}
40-
users={users}
41-
hasEmotioned={hasEmotioned}
42-
/>
43-
}
36+
content={<UsersPanel name={name} count={count} users={users} />}
37+
interactive={false}
4438
noPadding
4539
>
4640
<Wrapper

0 commit comments

Comments
 (0)