@ -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
|
||||
|
||||
@ -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,
|
||||
})
|
||||
|
||||
|
||||
@ -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<string | undefined>(undefined)
|
||||
const [articleId, setArticleId] = useState<string | undefined>(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 (
|
||||
<PrimaryLayout
|
||||
@ -80,7 +81,7 @@ export default function ArticleSavingRequestPage(): JSX.Element {
|
||||
fontSize={readerSettings.fontSize}
|
||||
lineHeight={readerSettings.lineHeight}
|
||||
>
|
||||
{url ? <PrimaryContent url={url} /> : <Loader />}
|
||||
{articleId ? <PrimaryContent articleId={articleId} /> : <Loader />}
|
||||
</SkeletonArticleContainer>
|
||||
</VStack>
|
||||
</PrimaryLayout>
|
||||
@ -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(() => {
|
||||
@ -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<string | undefined>(undefined)
|
||||
const [requestID, setRequestID] = useState<string | undefined>(undefined)
|
||||
const [username, setUsername] = useState<string | undefined>(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 (
|
||||
<PrimaryLayout
|
||||
@ -33,8 +33,8 @@ export default function LinkRequestPage(): JSX.Element {
|
||||
<Box
|
||||
css={{ bg: '$grayBase', height: '100vh', width: '100vw', px: '16px' }}
|
||||
>
|
||||
{url && username ? (
|
||||
<PrimaryContent url={url} username={username} />
|
||||
{requestID && username ? (
|
||||
<PrimaryContent requestID={requestID} username={username} />
|
||||
) : (
|
||||
<Loader />
|
||||
)}
|
||||
@ -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(() => {
|
||||
@ -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<string | undefined>(undefined)
|
||||
const [articleId, setArticleId] = useState<string | undefined>(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 (
|
||||
<PrimaryLayout
|
||||
@ -77,7 +78,7 @@ export default function ArticleSavingRequestPage(): JSX.Element {
|
||||
fontSize={readerSettings.fontSize}
|
||||
lineHeight={readerSettings.lineHeight}
|
||||
>
|
||||
{url ? <PrimaryContent url={url} /> : <Loader />}
|
||||
{articleId ? <PrimaryContent articleId={articleId} /> : <Loader />}
|
||||
</SkeletonArticleContainer>
|
||||
</VStack>
|
||||
</PrimaryLayout>
|
||||
@ -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(() => {
|
||||
Reference in New Issue
Block a user