Show unable to parse if page is failed to save within 30 seconds

This commit is contained in:
Hongbo Wu 2022-05-04 11:55:16 +08:00
parent fb96265a00
commit 80d0146f72
3 changed files with 7 additions and 4 deletions

View file

@ -102,7 +102,7 @@ const FORCE_PUPPETEER_URLS = [
/twitter\.com\/(?:#!\/)?(\w+)\/status(?:es)?\/(\d+)(?:\/.*)?/,
/^((?:https?:)?\/\/)?((?:www|m)\.)?((?:youtube\.com|youtu.be))(\/(?:[\w-]+\?v=|embed\/|v\/)?)([\w-]+)(\S+)?$/,
]
const UNPARSEABLE_CONTENT = 'We were unable to parse this page.'
const UNPARSEABLE_CONTENT = '<p>We were unable to parse this page.</p>'
export type CreateArticlesSuccessPartial = Merge<
CreateArticleSuccess,
@ -434,7 +434,7 @@ export const getArticleResolver: ResolverFn<
if (
page.state === ArticleSavingRequestStatus.Processing &&
new Date(page.createdAt).getTime() < new Date().getTime() - 1000 * 60
new Date(page.createdAt).getTime() < new Date().getTime() - 1000 * 30
) {
page.content = UNPARSEABLE_CONTENT
page.description = UNPARSEABLE_CONTENT

View file

@ -96,7 +96,6 @@ export const createPageSaveRequest = async (
const existingPage = await getPageByParam({
userId,
url,
state: ArticleSavingRequestStatus.Succeeded,
})
if (existingPage) {
console.log('Page already exists', url)

View file

@ -259,7 +259,11 @@ export function HomeFeedContainer(props: HomeFeedContainerProps): JSX.Element {
const username = viewerData?.me?.profile.username
if (username) {
setActiveCardId(item.node.id)
if (item.node.state === State.PROCESSING) {
if (
item.node.state === State.PROCESSING &&
new Date(item.node.createdAt).getTime() >=
new Date().getTime() - 1000 * 30
) {
router.push(`/${username}/links/${item.node.id}`)
} else {
router.push(`/${username}/${item.node.slug}`)