Skip to content

Commit

Permalink
Merge pull request #4965 from thematters/fix/remove-unused-tag-count
Browse files Browse the repository at this point in the history
  • Loading branch information
pauljusti authored Dec 4, 2024
2 parents b317d03 + ad84630 commit e8b95e6
Show file tree
Hide file tree
Showing 14 changed files with 6 additions and 137 deletions.
16 changes: 0 additions & 16 deletions src/components/GQL/fragments/tag.ts

This file was deleted.

15 changes: 0 additions & 15 deletions src/components/GQL/queries/tagArticlesCount.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/GQL/updates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export * from './circleFollowers'
export * from './commentDetail'
export * from './draftAssets'
export * from './momentDetail'
export * from './tagArticlesCount'
export * from './userCollectionDetail'
export * from './userCollections'
export * from './userCollectionsArticles'
Expand Down
48 changes: 0 additions & 48 deletions src/components/GQL/updates/tagArticlesCount.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Tag/ArticleTag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ ArticleTag.fragments = {
id
content
numArticles
numAuthors
}
`,
}
1 change: 0 additions & 1 deletion src/components/Tag/InlineTag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ InlineTag.fragments = {
id
content
numArticles
numAuthors
}
`,
}
1 change: 0 additions & 1 deletion src/components/Tag/ListTag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ ListTag.fragments = {
id
content
numArticles
numAuthors
}
`,
}
1 change: 0 additions & 1 deletion src/components/Tag/PlainTag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ PlainTag.fragments = {
id
content
numArticles
numAuthors
}
`,
}
1 change: 0 additions & 1 deletion src/components/TagDigest/Feed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const fragments = {
id
content
numArticles
numAuthors
}
`,
}
Expand Down
5 changes: 2 additions & 3 deletions src/views/Home/Sidebar/Tags/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useContext } from 'react'
import { analytics } from '~/common/utils'
import {
List,
ListTag,
QueryError,
ShuffleButton,
SpinnerBlock,
Expand Down Expand Up @@ -33,14 +32,14 @@ const SIDEBAR_TAGS = gql`
cursor
node {
id
...DigestTag
...TagDigestSidebarTag
}
}
}
}
}
}
${ListTag.fragments.tag}
${TagDigest.Sidebar.fragments.tag}
`

const Tags = () => {
Expand Down
10 changes: 2 additions & 8 deletions src/views/TagDetail/ArticlesCount/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { FormattedMessage } from 'react-intl'

import { numAbbr } from '~/common/utils'
import tagFragments from '~/components/GQL/fragments/tag'
import { ArticleCountTagFragment } from '~/gql/graphql'

import styles from './styles.module.css'

interface ArticlesCountProps {
tag: ArticleCountTagFragment
tag: { numArticles: number }
}

const ArticlesCount = ({ tag }: ArticlesCountProps) => {
const { totalCount } = tag.articles || { totalCount: 0 }
const totalCount = tag.numArticles

return (
<section className={styles.container}>
Expand All @@ -30,8 +28,4 @@ const ArticlesCount = ({ tag }: ArticlesCountProps) => {
)
}

ArticlesCount.fragments = {
tag: tagFragments.articleCount,
}

export default ArticlesCount
6 changes: 0 additions & 6 deletions src/views/TagDetail/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ import gql from 'graphql-tag'

import { TagBookmarkButton } from '~/components'

import ArticlesCount from './ArticlesCount'

const tagFragment = gql`
fragment TagFragment on Tag {
id
content
numArticles
numAuthors
selectedArticles: articles(input: { first: 0 }) {
totalCount
}
...ArticleCountTag
...TagBookmarkButtonTagPrivate
hottestArticles: articles(input: { first: 0, sortBy: byHottestDesc }) {
totalCount
Expand All @@ -25,12 +21,10 @@ const tagFragment = gql`
id
content
numArticles
numAuthors
}
}
}
}
${ArticlesCount.fragments.tag}
${TagBookmarkButton.fragments.tag.private}
`

Expand Down
26 changes: 2 additions & 24 deletions src/views/Tags/Feed.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import _get from 'lodash/get'
import { useEffect } from 'react'

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

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

export type FeedType = 'recommended' | 'hottest'

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

const query = ALL_TAGS_HOTTEST

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])
const { data, loading, error, fetchMore } = usePublicQuery<FeedQuery>(query)

if (loading) {
return <SpinnerBlock />
Expand Down
11 changes: 0 additions & 11 deletions src/views/Tags/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,3 @@ 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
}
}
}
`

0 comments on commit e8b95e6

Please sign in to comment.