diff --git a/src/components/CollectionDigest/Feed/index.tsx b/src/components/CollectionDigest/Feed/index.tsx index 0401141d41..29a2d001c4 100644 --- a/src/components/CollectionDigest/Feed/index.tsx +++ b/src/components/CollectionDigest/Feed/index.tsx @@ -119,7 +119,7 @@ type MemoizedCollectionDigestFeed = React.MemoExoticComponent< fragments: typeof fragments } -const CollectionDigestFeed = React.memo( +export const CollectionDigestFeed = React.memo( BaseCollectionDigestFeed, ({ collection: prevCollection }, { collection }) => { return ( @@ -134,5 +134,3 @@ const CollectionDigestFeed = React.memo( CollectionDigestFeed.Placeholder = Placeholder CollectionDigestFeed.fragments = fragments - -export default CollectionDigestFeed diff --git a/src/components/CollectionDigest/index.tsx b/src/components/CollectionDigest/index.tsx index fc19bf9a1e..f1fc7420e6 100644 --- a/src/components/CollectionDigest/index.tsx +++ b/src/components/CollectionDigest/index.tsx @@ -1,5 +1 @@ -import Feed from './Feed' - -export const CollectionDigest = { - Feed, -} +export * from './Feed' diff --git a/src/components/Dialogs/AddArticlesCollectionDialog/gql.ts b/src/components/Dialogs/AddArticlesCollectionDialog/gql.ts index 4b6ad87c20..42d3ccc4e5 100644 --- a/src/components/Dialogs/AddArticlesCollectionDialog/gql.ts +++ b/src/components/Dialogs/AddArticlesCollectionDialog/gql.ts @@ -1,8 +1,6 @@ import gql from 'graphql-tag' -// circular dependencies? 👇 -// import { ArticleDigestFeed } from '~/components' -import { ArticleDigestFeed } from '../../ArticleDigest/Feed' +import { ArticleDigestFeed } from '~/components/ArticleDigest/Feed' export const fragments = { user: gql` diff --git a/src/components/Dialogs/AddCollectionDialog/Content.tsx b/src/components/Dialogs/AddCollectionDialog/Content.tsx index c87251e3c9..cdb16f47a0 100644 --- a/src/components/Dialogs/AddCollectionDialog/Content.tsx +++ b/src/components/Dialogs/AddCollectionDialog/Content.tsx @@ -8,7 +8,7 @@ import { FormattedMessage, useIntl } from 'react-intl' import { KEYVALUE } from '~/common/enums' import { toPath, validateCollectionTitle } from '~/common/utils' import { - CollectionDigest, + CollectionDigestFeed, Dialog, Form, LanguageContext, @@ -38,7 +38,7 @@ const CREATE_COLLECTION = gql` ...CollectionDigestFeedCollection } } - ${CollectionDigest.Feed.fragments.collection} + ${CollectionDigestFeed.fragments.collection} ` const AddCollectionDialogContent: React.FC = ({ diff --git a/src/components/Dialogs/AddCollectionsArticleDialog/SelectDialogContent.tsx b/src/components/Dialogs/AddCollectionsArticleDialog/SelectDialogContent.tsx index 7fedf514db..c51c1b7086 100644 --- a/src/components/Dialogs/AddCollectionsArticleDialog/SelectDialogContent.tsx +++ b/src/components/Dialogs/AddCollectionsArticleDialog/SelectDialogContent.tsx @@ -36,9 +36,7 @@ const SelectDialogContent: React.FC = ({ const { data, loading } = usePublicQuery( ADD_COLLECTIONS_ARTICLE_USER_PUBLIC, - { - variables: { userName, id: articleId }, - } + { variables: { userName, id: articleId }, fetchPolicy: 'network-only' } ) const user = data?.user diff --git a/src/components/Dialogs/AddCollectionsArticleDialog/index.tsx b/src/components/Dialogs/AddCollectionsArticleDialog/index.tsx index 5c92c79e7f..b14d7f1853 100644 --- a/src/components/Dialogs/AddCollectionsArticleDialog/index.tsx +++ b/src/components/Dialogs/AddCollectionsArticleDialog/index.tsx @@ -39,6 +39,9 @@ const BaseAddCollectionsArticleDialog = ({ children, articleId, }: AddCollectionsArticleDialogProps) => { + // FIXME: circular dependencies + const { COLLECTION_DETAIL } = require('~/views/User/CollectionDetail/gql') + const viewer = useContext(ViewerContext) const { getQuery } = useRoute() @@ -77,6 +80,10 @@ const BaseAddCollectionsArticleDialog = ({ query: USER_COLLECTIONS, variables: { userName: viewer.userName }, }, + { + query: COLLECTION_DETAIL, + variables: { id: checked[0] }, + }, ], }) diff --git a/src/stories/components/CollectionDigest/Feed.stories.tsx b/src/stories/components/CollectionDigest/Feed.stories.tsx index cbb96c6f8e..9ff6ba6e54 100644 --- a/src/stories/components/CollectionDigest/Feed.stories.tsx +++ b/src/stories/components/CollectionDigest/Feed.stories.tsx @@ -2,18 +2,18 @@ import { MockedProvider } from '@apollo/react-testing' import { ComponentMeta, ComponentStory } from '@storybook/react' import React from 'react' -import { CollectionDigest } from '~/components' +import { CollectionDigestFeed } from '~/components' import { MOCK_COLLECTION } from '../../mocks' export default { title: 'Components/CollectionDigest', - component: CollectionDigest.Feed, -} as ComponentMeta + component: CollectionDigestFeed, +} as ComponentMeta -const Template: ComponentStory = (args) => ( +const Template: ComponentStory = (args) => ( - + ) diff --git a/src/views/User/CollectionDetail/CollectionArticles/gql.ts b/src/views/User/CollectionDetail/CollectionArticles/gql.ts index e9f48c7680..4e21245b00 100644 --- a/src/views/User/CollectionDetail/CollectionArticles/gql.ts +++ b/src/views/User/CollectionDetail/CollectionArticles/gql.ts @@ -1,6 +1,7 @@ import gql from 'graphql-tag' -import { ArticleDigestFeed, CollectionDigest } from '~/components' +import { ArticleDigestFeed } from '~/components/ArticleDigest/Feed' +import { CollectionDigestFeed } from '~/components/CollectionDigest/Feed' export const fragments = { collection: gql` @@ -22,6 +23,6 @@ export const fragments = { } ${ArticleDigestFeed.fragments.article.public} ${ArticleDigestFeed.fragments.article.private} - ${CollectionDigest.Feed.fragments.collection} + ${CollectionDigestFeed.fragments.collection} `, } diff --git a/src/views/User/Collections/Placeholder/index.tsx b/src/views/User/Collections/Placeholder/index.tsx index 42eec04a71..b111e0f3c2 100644 --- a/src/views/User/Collections/Placeholder/index.tsx +++ b/src/views/User/Collections/Placeholder/index.tsx @@ -1,16 +1,16 @@ -import { CollectionDigest, List } from '~/components' +import { CollectionDigestFeed, List } from '~/components' const Placeholder = () => { return ( - + - + - + ) diff --git a/src/views/User/Collections/UserCollections.tsx b/src/views/User/Collections/UserCollections.tsx index 51be608ba9..f475819c47 100644 --- a/src/views/User/Collections/UserCollections.tsx +++ b/src/views/User/Collections/UserCollections.tsx @@ -6,7 +6,7 @@ import PROFILE_COVER_DEFAULT from '@/public/static/images/profile-cover.png' import { analytics, mergeConnections, stripSpaces } from '~/common/utils' import { AddCollectionDialog, - CollectionDigest, + CollectionDigestFeed, Empty, Head, IconAdd20, @@ -169,7 +169,7 @@ const UserCollections = () => { {edges.map(({ node, cursor }, i) => ( - analytics.trackEvent('click_feed', { diff --git a/src/views/User/Collections/gql.ts b/src/views/User/Collections/gql.ts index 2233dbdfb1..066bff07da 100644 --- a/src/views/User/Collections/gql.ts +++ b/src/views/User/Collections/gql.ts @@ -1,6 +1,6 @@ import gql from 'graphql-tag' -import CollectionDigestFeed from '~/components/CollectionDigest/Feed' +import { CollectionDigestFeed } from '~/components/CollectionDigest/Feed' const fragments = gql` fragment CollectionsUser on User {