Skip to content

Commit c5c7f23

Browse files
committed
fix: remove fuck unstable_cache
Signed-off-by: Innei <[email protected]>
1 parent 7012092 commit c5c7f23

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

src/app/(app)/(home)/layout.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { dehydrate } from '@tanstack/react-query'
22
import type { PropsWithChildren } from 'react'
33

44
import { QueryHydrate } from '~/components/common/QueryHydrate'
5-
import { getOrSetCache } from '~/lib/cache'
5+
import { onlyGetOrSetCacheInVercelButFallback } from '~/lib/cache'
66
import { isShallowEqualArray } from '~/lib/lodash'
77
import { getQueryClient } from '~/lib/query-client.server'
88
import { apiClient } from '~/lib/request'
@@ -18,7 +18,7 @@ export default async function HomeLayout(props: PropsWithChildren) {
1818
.fetchQuery({
1919
queryKey,
2020
queryFn: async () => {
21-
return getOrSetCache(
21+
return onlyGetOrSetCacheInVercelButFallback(
2222
'aggregate-top',
2323
async () => {
2424
return (await apiClient.aggregate.getTop(5)).$serialized

src/app/(app)/layout.tsx

+13-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { cache } from 'react'
12
import { ToastContainer } from 'react-toastify'
2-
import { unstable_cache } from 'next/cache'
33
import type { Viewport } from 'next'
44
import type { PropsWithChildren } from 'react'
55

@@ -14,7 +14,7 @@ import { AccentColorStyleInjector } from '~/components/modules/shared/AccentColo
1414
import { SearchPanelWithHotKey } from '~/components/modules/shared/SearchFAB'
1515
import { TocAutoScroll } from '~/components/modules/toc/TocAutoScroll'
1616
import { attachUAAndRealIp } from '~/lib/attach-ua'
17-
import { getOrSetCache } from '~/lib/cache'
17+
import { onlyGetOrSetCacheInVercelButFallback } from '~/lib/cache'
1818
import { sansFont, serifFont } from '~/lib/fonts'
1919
import { getQueryClient } from '~/lib/query-client.server'
2020
import { AggregationProvider } from '~/providers/root/aggregation-data-provider'
@@ -43,23 +43,19 @@ export function generateViewport(): Viewport {
4343
}
4444

4545
const key = 'root-data'
46-
const fetchAggregationData = unstable_cache(
47-
async () => {
48-
const queryClient = getQueryClient()
46+
const fetchAggregationData = cache(async () => {
47+
const queryClient = getQueryClient()
4948

50-
return getOrSetCache(
51-
key,
52-
async () => {
53-
attachUAAndRealIp()
49+
return onlyGetOrSetCacheInVercelButFallback(
50+
key,
51+
async () => {
52+
attachUAAndRealIp()
5453

55-
return queryClient.fetchQuery(queries.aggregation.root())
56-
},
57-
revalidate,
58-
)
59-
},
60-
[key],
61-
{ revalidate },
62-
)
54+
return queryClient.fetchQuery(queries.aggregation.root())
55+
},
56+
revalidate,
57+
)
58+
})
6359
export const generateMetadata = async () => {
6460
const fetchedData = await fetchAggregationData()
6561

0 commit comments

Comments
 (0)