From cad4afbe8c5e4e96366e159f45f33d9940f37f2f Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 17 Mar 2023 16:58:08 +0800 Subject: [PATCH] Revert "Update frontend" This reverts commit cfb62a3995202065ea164c90286756402c218e43. --- .../templates/homeFeed/HomeFeedContainer.tsx | 2 +- .../queries/useGetArticleSavingStatus.tsx | 10 +++---- .../[username]/links/{[url].tsx => [id].tsx} | 27 ++++++++++--------- .../link-request/{[url].tsx => [id].tsx} | 22 +++++++-------- .../pages/article/sr/{[url].tsx => [id].tsx} | 27 ++++++++++--------- 5 files changed, 45 insertions(+), 43 deletions(-) rename packages/web/pages/[username]/links/{[url].tsx => [id].tsx} (91%) rename packages/web/pages/app/[username]/link-request/{[url].tsx => [id].tsx} (87%) rename packages/web/pages/article/sr/{[url].tsx => [id].tsx} (91%) diff --git a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx index 719a2526e..c4b0134f6 100644 --- a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx +++ b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx @@ -288,7 +288,7 @@ export function HomeFeedContainer(): JSX.Element { if (username) { setActiveCardId(item.node.id) if (item.node.state === State.PROCESSING) { - router.push(`/${username}/links/${item.node.url}`) + router.push(`/${username}/links/${item.node.id}`) } else { const dl = item.node.pageType === PageType.HIGHLIGHTS diff --git a/packages/web/lib/networking/queries/useGetArticleSavingStatus.tsx b/packages/web/lib/networking/queries/useGetArticleSavingStatus.tsx index da09283eb..ff170293c 100644 --- a/packages/web/lib/networking/queries/useGetArticleSavingStatus.tsx +++ b/packages/web/lib/networking/queries/useGetArticleSavingStatus.tsx @@ -6,7 +6,7 @@ import { makeGqlFetcher } from '../networkHelpers' import { ArticleAttributes } from './useGetArticleQuery' type ArticleSavingStatusInput = { - url: string + id: string } type ArticleSavingStatusResponse = { @@ -48,11 +48,11 @@ type ArticleSavingStatusError = | 'unauthorized' export function useGetArticleSavingStatus({ - url, + id, }: ArticleSavingStatusInput): ArticleSavingStatusResponse { const query = gql` - query ArticleSavingRequest($url: String!) { - articleSavingRequest(url: $url) { + query ArticleSavingRequest($id: ID!) { + articleSavingRequest(id: $id) { ... on ArticleSavingRequestSuccess { articleSavingRequest { id @@ -85,7 +85,7 @@ export function useGetArticleSavingStatus({ ` // poll twice a second - const { data, error } = useSWR([query, url], makeGqlFetcher({ url }), { + const { data, error } = useSWR([query, id], makeGqlFetcher({ id }), { refreshInterval: 500, }) diff --git a/packages/web/pages/[username]/links/[url].tsx b/packages/web/pages/[username]/links/[id].tsx similarity index 91% rename from packages/web/pages/[username]/links/[url].tsx rename to packages/web/pages/[username]/links/[id].tsx index 1ad0d59b9..3b7ca4109 100644 --- a/packages/web/pages/[username]/links/[url].tsx +++ b/packages/web/pages/[username]/links/[id].tsx @@ -1,29 +1,30 @@ import { useRouter } from 'next/router' import { useEffect, useState } from 'react' -import TopBarProgress from 'react-topbar-progress-indicator' -import { VStack } from '../../../components/elements/LayoutPrimitives' -import { ArticleActionsMenu } from '../../../components/templates/article/ArticleActionsMenu' -import { SkeletonArticleContainer } from '../../../components/templates/article/SkeletonArticleContainer' +import { useGetArticleSavingStatus } from '../../../lib/networking/queries/useGetArticleSavingStatus' import { PrimaryLayout } from '../../../components/templates/PrimaryLayout' import { - ErrorComponent, Loader + Loader, + ErrorComponent, } from '../../../components/templates/SavingRequest' +import { ArticleActionsMenu } from '../../../components/templates/article/ArticleActionsMenu' +import { VStack } from '../../../components/elements/LayoutPrimitives' import { theme } from '../../../components/tokens/stitches.config' -import { useReaderSettings } from '../../../lib/hooks/useReaderSettings' -import { useGetArticleSavingStatus } from '../../../lib/networking/queries/useGetArticleSavingStatus' import { applyStoredTheme } from '../../../lib/themeUpdater' +import { useReaderSettings } from '../../../lib/hooks/useReaderSettings' +import { SkeletonArticleContainer } from '../../../components/templates/article/SkeletonArticleContainer' +import TopBarProgress from 'react-topbar-progress-indicator' export default function ArticleSavingRequestPage(): JSX.Element { const router = useRouter() const readerSettings = useReaderSettings() - const [url, setUrl] = useState(undefined) + const [articleId, setArticleId] = useState(undefined) applyStoredTheme(false) useEffect(() => { if (!router.isReady) return - setUrl(router.query.url as string) - }, [router.isReady, router.query.url]) + setArticleId(router.query.id as string) + }, [router.isReady, router.query.id]) return ( - {url ? : } + {articleId ? : } @@ -88,7 +89,7 @@ export default function ArticleSavingRequestPage(): JSX.Element { } type PrimaryContentProps = { - url: string + articleId: string } function PrimaryContent(props: PrimaryContentProps): JSX.Element { @@ -96,7 +97,7 @@ function PrimaryContent(props: PrimaryContentProps): JSX.Element { const [timedOut, setTimedOut] = useState(false) const { successRedirectPath, error } = useGetArticleSavingStatus({ - url: props.url, + id: props.articleId, }) useEffect(() => { diff --git a/packages/web/pages/app/[username]/link-request/[url].tsx b/packages/web/pages/app/[username]/link-request/[id].tsx similarity index 87% rename from packages/web/pages/app/[username]/link-request/[url].tsx rename to packages/web/pages/app/[username]/link-request/[id].tsx index b116b1de8..74ba9279c 100644 --- a/packages/web/pages/app/[username]/link-request/[url].tsx +++ b/packages/web/pages/app/[username]/link-request/[id].tsx @@ -1,25 +1,25 @@ import { useRouter } from 'next/router' import { useEffect, useState } from 'react' -import { useSWRConfig } from 'swr' import { Box } from '../../../../components/elements/LayoutPrimitives' -import { PrimaryLayout } from '../../../../components/templates/PrimaryLayout' -import { ErrorComponent } from '../../../../components/templates/SavingRequest' -import { cacheArticle } from '../../../../lib/networking/queries/useGetArticleQuery' import { useGetArticleSavingStatus } from '../../../../lib/networking/queries/useGetArticleSavingStatus' +import { ErrorComponent } from '../../../../components/templates/SavingRequest' +import { useSWRConfig } from 'swr' +import { cacheArticle } from '../../../../lib/networking/queries/useGetArticleQuery' +import { PrimaryLayout } from '../../../../components/templates/PrimaryLayout' import { applyStoredTheme } from '../../../../lib/themeUpdater' export default function LinkRequestPage(): JSX.Element { applyStoredTheme(false) // false to skip server sync const router = useRouter() - const [url, setUrl] = useState(undefined) + const [requestID, setRequestID] = useState(undefined) const [username, setUsername] = useState(undefined) useEffect(() => { if (!router.isReady) return - setUrl(router.query.url as string) + setRequestID(router.query.id as string) setUsername(router.query.username as string) - }, [router.isReady, router.query.url, router.query.username]) + }, [router.isReady, router.query.id, router.query.username]) return ( - {url && username ? ( - + {requestID && username ? ( + ) : ( )} @@ -48,7 +48,7 @@ function Loader(): JSX.Element { } type PrimaryContentProps = { - url: string + requestID: string username: string } @@ -58,7 +58,7 @@ function PrimaryContent(props: PrimaryContentProps): JSX.Element { const [timedOut, setTimedOut] = useState(false) const { successRedirectPath, article, error } = useGetArticleSavingStatus({ - url: props.url, + id: props.requestID, }) useEffect(() => { diff --git a/packages/web/pages/article/sr/[url].tsx b/packages/web/pages/article/sr/[id].tsx similarity index 91% rename from packages/web/pages/article/sr/[url].tsx rename to packages/web/pages/article/sr/[id].tsx index 1a5484c85..90ef594c8 100644 --- a/packages/web/pages/article/sr/[url].tsx +++ b/packages/web/pages/article/sr/[id].tsx @@ -1,29 +1,30 @@ import { useRouter } from 'next/router' import { useEffect, useState } from 'react' -import TopBarProgress from 'react-topbar-progress-indicator' -import { VStack } from '../../../components/elements/LayoutPrimitives' -import { ArticleActionsMenu } from '../../../components/templates/article/ArticleActionsMenu' -import { SkeletonArticleContainer } from '../../../components/templates/article/SkeletonArticleContainer' +import { useGetArticleSavingStatus } from '../../../lib/networking/queries/useGetArticleSavingStatus' import { PrimaryLayout } from '../../../components/templates/PrimaryLayout' import { - ErrorComponent, Loader + Loader, + ErrorComponent, } from '../../../components/templates/SavingRequest' +import { ArticleActionsMenu } from '../../../components/templates/article/ArticleActionsMenu' +import { VStack } from '../../../components/elements/LayoutPrimitives' import { theme } from '../../../components/tokens/stitches.config' -import { useReaderSettings } from '../../../lib/hooks/useReaderSettings' -import { useGetArticleSavingStatus } from '../../../lib/networking/queries/useGetArticleSavingStatus' import { applyStoredTheme } from '../../../lib/themeUpdater' +import { useReaderSettings } from '../../../lib/hooks/useReaderSettings' +import { SkeletonArticleContainer } from '../../../components/templates/article/SkeletonArticleContainer' +import TopBarProgress from 'react-topbar-progress-indicator' export default function ArticleSavingRequestPage(): JSX.Element { const router = useRouter() const readerSettings = useReaderSettings() - const [url, setUrl] = useState(undefined) + const [articleId, setArticleId] = useState(undefined) applyStoredTheme(false) useEffect(() => { if (!router.isReady) return - setUrl(router.query.url as string) - }, [router.isReady, router.query.url]) + setArticleId(router.query.id as string) + }, [router.isReady, router.query.id]) return ( - {url ? : } + {articleId ? : } @@ -85,7 +86,7 @@ export default function ArticleSavingRequestPage(): JSX.Element { } type PrimaryContentProps = { - url: string + articleId: string } function PrimaryContent(props: PrimaryContentProps): JSX.Element { @@ -93,7 +94,7 @@ function PrimaryContent(props: PrimaryContentProps): JSX.Element { const [timedOut, setTimedOut] = useState(false) const { successRedirectPath, error } = useGetArticleSavingStatus({ - url: props.url, + id: props.articleId, }) useEffect(() => {