Skip to content

Commit

Permalink
fix: note layout loading flash
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei committed Oct 2, 2023
1 parent 98f372d commit b4966e3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/app/notes/[id]/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import NoteLoading from '../loading'
import { FullPageLoading } from '~/components/ui/loading'

export default NoteLoading
export default FullPageLoading
3 changes: 0 additions & 3 deletions src/app/notes/loading.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/app/notes/redirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useRouter } from 'next/navigation'

import { routeBuilder, Routes } from '~/lib/route-builder'

import NoteLoading from './loading'
import FullPageLoading from '../friends/loading'

export default function NodeRedirect({ nid }: { nid: number }) {
const router = useRouter()
Expand All @@ -16,5 +16,5 @@ export default function NodeRedirect({ nid }: { nid: number }) {
}),
)
}, [nid])
return <NoteLoading />
return <FullPageLoading />
}
25 changes: 16 additions & 9 deletions src/components/widgets/xlog/XLogSummaryAsync.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client'

import { queryClient } from '~/providers/root/react-query-provider'
import { Suspense } from 'react'

import { clsxm } from '~/lib/helper'
Expand All @@ -11,16 +12,22 @@ const fetchData = async (cid: string) => {
return null
}

return fetch(
`/api/xlog/summary?cid=${cid}&lang=${navigator.language.split('-')[0]}`,
{
next: {
revalidate: 60 * 10,
},
return queryClient.fetchQuery({
queryKey: ['xlog', 'summary', cid],
staleTime: 6000,
cacheTime: 6000,
queryFn: () => {
const lang =
'navigator' in globalThis ? navigator.language.split('-')[0] : 'zh'
return fetch(`/api/xlog/summary?cid=${cid}&lang=${lang}`, {
next: {
revalidate: 60 * 10,
},
})
.then((res) => res.json())
.catch(() => null)
},
)
.then((res) => res.json())
.catch(() => null)
})
}

export const XLogSummaryAsync = async (
Expand Down

1 comment on commit b4966e3

@vercel
Copy link

@vercel vercel bot commented on b4966e3 Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

shiro – ./

shiro-innei.vercel.app
innei.in
shiro-git-main-innei.vercel.app
springtide.vercel.app

Please sign in to comment.