Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix product test feedback #4963

Merged
merged 11 commits into from
Dec 3, 2024
3 changes: 3 additions & 0 deletions lang/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -2544,6 +2544,9 @@
"iEJeQH": {
"defaultMessage": "Liker ID"
},
"iIitRg": {
"defaultMessage": "Tag not bookmarked yet"
},
"iNZdM/": {
"defaultMessage": "Switch to support creators with the Optimism network {br} Make support more convenient and affordable",
"description": "src/components/Forms/PaymentForm/SwitchNetwork/index.tsx"
Expand Down
5 changes: 4 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@
"defaultMessage": "Agree"
},
"IUS82d": {
"defaultMessage": "Recommended Authors",
"defaultMessage": "Tag active authors",
"description": "src/views/TagDetail/RecommendedAuthors/index.tsx"
},
"IXycMo": {
Expand Down Expand Up @@ -2544,6 +2544,9 @@
"iEJeQH": {
"defaultMessage": "Liker ID"
},
"iIitRg": {
"defaultMessage": "Tag not bookmarked yet"
},
"iNZdM/": {
"defaultMessage": "Switch to support creators with the Optimism network {br} Make support more convenient and affordable",
"description": "src/components/Forms/PaymentForm/SwitchNetwork/index.tsx"
Expand Down
3 changes: 3 additions & 0 deletions lang/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -2544,6 +2544,9 @@
"iEJeQH": {
"defaultMessage": "设置 Liker ID"
},
"iIitRg": {
"defaultMessage": "尚未收藏标签"
},
"iNZdM/": {
"defaultMessage": "切换后即可支持创作者,采用 Optimism 网络{br}让支持更方便且费用低廉",
"description": "src/components/Forms/PaymentForm/SwitchNetwork/index.tsx"
Expand Down
3 changes: 3 additions & 0 deletions lang/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -2544,6 +2544,9 @@
"iEJeQH": {
"defaultMessage": "設置 Liker ID"
},
"iIitRg": {
"defaultMessage": "尚未收藏標籤"
},
"iNZdM/": {
"defaultMessage": "切換後即可支持創作者,採用 Optimism 網路{br}讓支持更方便且費用低廉",
"description": "src/components/Forms/PaymentForm/SwitchNetwork/index.tsx"
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils/text/tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const stripTagAllPunct = (content: string) => {
return words[0]
default:
const [first, ...rest] = words
return `${first} ${rest.join('')}`
return `${first} ${rest.join(' ')}`
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/components/Buttons/TagBookmark/Bookmark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ interface BookmarkProps {
const Bookmark = ({ tag }: BookmarkProps) => {
const viewer = useContext(ViewerContext)
const intl = useIntl()
const {
ME_BOOKMARK_TAGS_FEED,
} = require('~/views/Me/Bookmarks/BookmarksTags')
const [bookmark] = useMutation<ToggleBookmarkTagMutation>(
TOGGLE_BOOKMARK_TAG,
{
Expand All @@ -35,6 +38,11 @@ const Bookmark = ({ tag }: BookmarkProps) => {
},
}
: undefined,
refetchQueries: [
{
query: ME_BOOKMARK_TAGS_FEED,
},
],
}
)

Expand Down
15 changes: 15 additions & 0 deletions src/components/Empty/EmptyTagBookmark.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { FormattedMessage } from 'react-intl'

import { ReactComponent as IconSave } from '@/public/static/icons/24px/save.svg'
import { Empty, Icon } from '~/components'

export const EmptyTagBookmark = () => (
<Empty
icon={<Icon icon={IconSave} size={64} />}
description={
<>
<FormattedMessage id="iIitRg" defaultMessage="Tag not bookmarked yet" />
</>
}
/>
)
1 change: 1 addition & 0 deletions src/components/Empty/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from './EmptyResponse'
export * from './EmptySearch'
export * from './EmptyTag'
export * from './EmptyTagArticles'
export * from './EmptyTagBookmark'
export * from './EmptyTransaction'
export * from './EmptyTransactionCurrency'
export * from './EmptyTransactionSubscription'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Slides/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface SlidesProps {
}

interface SlideItemProps {
size?: 'sm' | 'md'
size?: 'xs' | 'sm' | 'md'
onClick?: () => any
}

Expand Down
4 changes: 4 additions & 0 deletions src/components/Slides/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
background: var(--color-grey-lighter);
}

.sizeXs {
width: 15rem;
}

.sizeSm {
width: 18rem;
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/Tag/InlineTag/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@

& .name {
@mixin line-clamp;
@mixin fix-cropped-letters;

line-height: inherit;
line-height: 1.01;
color: var(--color-black);
}

Expand Down
51 changes: 0 additions & 51 deletions src/components/TagDigest/Bookmark/Bookmark.test.tsx

This file was deleted.

1 change: 1 addition & 0 deletions src/components/TagDigest/Feed/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

font-size: var(--text16);
line-height: 1.5rem; /* 24px */
word-break: break-all;
}

& .nums {
Expand Down
14 changes: 11 additions & 3 deletions src/views/Me/Bookmarks/BookmarksTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FormattedMessage, useIntl } from 'react-intl'

import { mergeConnections } from '~/common/utils'
import {
EmptyBookmark,
EmptyTagBookmark,
Head,
InfiniteScroll,
Layout,
Expand All @@ -18,7 +18,7 @@ import { MeBookmarkTagsFeedQuery } from '~/gql/graphql'

import BookmarksTabs from './BookmarksTabs'

const ME_BOOKMARK_TAGS_FEED = gql`
export const ME_BOOKMARK_TAGS_FEED = gql`
query MeBookmarkTagsFeed($after: String) {
viewer {
id
Expand Down Expand Up @@ -57,7 +57,15 @@ const BaseMeBookmarksTags = () => {
const { edges, pageInfo } = data?.viewer?.bookmarkedTags || {}

if (!edges || edges.length <= 0 || !pageInfo) {
return <EmptyBookmark />
return <EmptyTagBookmark />
}

const hasFollowedTags = edges.some(
({ node }) => node.__typename === 'Tag' && node.isFollower
)

if (!hasFollowedTags) {
return <EmptyTagBookmark />
}

const loadMore = () =>
Expand Down
47 changes: 36 additions & 11 deletions src/views/TagDetail/RecommendedAuthors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import _random from 'lodash/random'
import { FormattedMessage } from 'react-intl'

import { analytics } from '~/common/utils'
import { List, usePublicQuery, UserDigest } from '~/components'
import { List, Slides, usePublicQuery, UserDigest } from '~/components'
import { TagDetailRecommendedAuthorsQuery } from '~/gql/graphql'

import { RECOMMENDED_AUTHORS } from './gql'
Expand All @@ -32,6 +32,7 @@ const RecommendedAuthors: React.FC<RecommendedAuthorsProps> = ({
tagId,
inSidebar,
}) => {
const perColumn = 3
const { data } = usePublicQuery<TagDetailRecommendedAuthorsQuery>(
RECOMMENDED_AUTHORS,
{
Expand Down Expand Up @@ -59,25 +60,49 @@ const RecommendedAuthors: React.FC<RecommendedAuthorsProps> = ({
[styles.inSidebar]: inSidebar,
})

if (inSidebar) {
return (
<section className={recommendedAuthorsClasses}>
<RecommendedAuthorsHeader />
<section className={styles.users}>
<List hasBorder={false}>
{edges.map(({ node, cursor }, i) => (
<List.Item key={node.id}>
<UserDigest.Rich
user={node}
spacing={[0, 0]}
bgColor="none"
onClick={() => trackRecommendedAuthors(i, node.id)}
hasFollow={false}
hasState={false}
/>
</List.Item>
))}
</List>
</section>
</section>
)
}

return (
<section className={recommendedAuthorsClasses}>
<RecommendedAuthorsHeader />
<section className={styles.users}>
<List hasBorder={false}>
{edges.map(({ node, cursor }, i) => (
<List.Item key={node.id}>
<Slides header={<RecommendedAuthorsHeader />}>
{_chunk(edges, perColumn).map((chunks, i) => (
<Slides.Item size="xs" key={i}>
{chunks.map(({ node, cursor }) => (
<UserDigest.Rich
key={node.id}
user={node}
spacing={[0, 0]}
spacing={[12, 0]}
bgColor="none"
onClick={() => trackRecommendedAuthors(i, node.id)}
hasFollow={false}
hasState={false}
/>
</List.Item>
))}
</List>
</section>
))}
</Slides.Item>
))}
</Slides>
</section>
)
}
Expand Down
11 changes: 8 additions & 3 deletions src/views/TagDetail/RecommendedAuthors/styles.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
.recommendedAuthors {
padding-bottom: var(--sp24);
margin-top: var(--sp24);
padding-bottom: var(--sp20);
margin-top: var(--sp8);
border-bottom: 1px dashed var(--color-grey-light);

@media (--sm-up) {
padding-bottom: var(--sp24);
margin-top: var(--sp24);
}
}

.inSidebar {
Expand All @@ -11,7 +16,7 @@
}

.header {
margin-bottom: var(--sp18);
margin-bottom: var(--sp6);
font-size: var(--text14);
font-weight: var(--font-medium);
line-height: 1.375rem;
Expand Down
26 changes: 24 additions & 2 deletions src/views/Tags/Feed.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _get from 'lodash/get'
import { useEffect } from 'react'

import { analytics, mergeConnections } from '~/common/utils'
import {
Expand All @@ -11,7 +12,7 @@ import {
} from '~/components'
import { AllTagsHottestQuery } from '~/gql/graphql'

import { ALL_TAGS_HOTTEST } from './gql'
import { ALL_TAGS_HOTTEST, TAG_REACTIVE_DATA } from './gql'

export type FeedType = 'recommended' | 'hottest'

Expand All @@ -26,7 +27,28 @@ const Feed = ({ type }: Props) => {

const query = ALL_TAGS_HOTTEST

const { data, loading, error, fetchMore } = usePublicQuery<FeedQuery>(query)
const { data, loading, error, fetchMore, client } =
usePublicQuery<FeedQuery>(query)

// fetch the latest tag data
const loadTagReactiveData = (publicData?: FeedQuery) => {
const publicEdges = publicData?.viewer?.recommendation.tags.edges || []
const publicIds = publicEdges.map(({ node }) => node.id)

if (publicIds.length <= 0) {
return
}

client.query({
query: TAG_REACTIVE_DATA,
fetchPolicy: 'network-only',
variables: { ids: publicIds },
})
}

useEffect(() => {
loadTagReactiveData(data)
}, [data])

if (loading) {
return <SpinnerBlock />
Expand Down
11 changes: 11 additions & 0 deletions src/views/Tags/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@ export const ALL_TAGS_HOTTEST = gql`
}
${TagDigest.Feed.fragments.tag}
`

export const TAG_REACTIVE_DATA = gql`
query TagReactiveData($ids: [ID!]!) {
nodes(input: { ids: $ids }) {
id
... on Tag {
numArticles
}
}
}
`
Loading