Skip to content

Commit

Permalink
fix: persist typing
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Jul 15, 2024
1 parent b1f9ee2 commit 6031d85
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 34 deletions.
2 changes: 1 addition & 1 deletion reporter-assets
3 changes: 1 addition & 2 deletions src/app/(app)/timeline/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export default definePrerenderPage<{
}[type]
const queryClient = getQueryClient()
await queryClient.fetchQuery({
queryKey: ['timeline'],
meta: { nextType, year },
queryKey: ['timeline', nextType, year],
queryFn: async () => {
return await apiClient.aggregate
.getTimeline({
Expand Down
3 changes: 1 addition & 2 deletions src/components/modules/post/fab/PostTagsFAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,11 @@ export const TagDetailModal = (props: { name: string }) => {
return (await apiClient.category.getTagByName(tagName)).data
},
staleTime: 1000 * 60 * 60 * 24,
meta: {},
})
const { dismissAll } = useModalStack()
if (isLoading)
return (
<div className="center flex h-24 w-full">
<div className="flex h-24 w-full center">
<div className="loading loading-dots loading-md" />
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion src/providers/root/react-query-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const queryClient = new QueryClient({

declare module '@tanstack/react-query' {
interface Meta {
queryMeta: { persist: boolean }
queryMeta: { persist?: boolean }
}

interface Register extends Meta {}
Expand Down
3 changes: 0 additions & 3 deletions src/queries/definition/aggregation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ export const aggregation = {
},
),
gcTime: 1000 * 60 * 10,
meta: {
forceHydration: true,
},
staleTime: isServer ? 1000 * 60 * 10 : undefined,
}),
}
13 changes: 1 addition & 12 deletions src/queries/definition/note.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useMutation } from '@tanstack/react-query'
import dayjs from 'dayjs'
import type {
NoteModel,
NoteWrappedPayload,
Expand All @@ -10,7 +9,6 @@ import type { NoteDto } from '~/models/writing'
import { useResetAutoSaverData } from '~/components/modules/dashboard/writing/BaseWritingProvider'
import { cloneDeep } from '~/lib/lodash'
import { apiClient } from '~/lib/request'
import { routeBuilder, Routes } from '~/lib/route-builder'
import { toast } from '~/lib/toast'

import { defineQuery } from '../helper'
Expand All @@ -20,16 +18,7 @@ export const note = {
byNid: (nid: string, password?: string | null, token?: string) =>
defineQuery({
queryKey: ['note', nid, token],
meta: {
hydrationRoutePath: routeBuilder(Routes.Note, { id: nid }),
shouldHydration: (data: NoteWrappedPayload) => {
const note = data?.data
const isSecret = note?.publicAt
? dayjs(note?.publicAt).isAfter(new Date())
: false
return !isSecret && !data.data.hide
},
},

queryFn: async ({ queryKey }) => {
const [, id] = queryKey

Expand Down
7 changes: 1 addition & 6 deletions src/queries/definition/page.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { apiClient } from '~/lib/request'
import { routeBuilder, Routes } from '~/lib/route-builder'

import { defineQuery } from '../helper'

export const page = {
bySlug: (slug: string) =>
defineQuery({
queryKey: ['page', slug],
meta: {
hydrationRoutePath: routeBuilder(Routes.Page, {
slug,
}),
},

queryFn: async ({ queryKey }) => {
const [, slug] = queryKey

Expand Down
8 changes: 1 addition & 7 deletions src/queries/definition/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { PostDto } from '~/models/writing'
import { useResetAutoSaverData } from '~/components/modules/dashboard/writing/BaseWritingProvider'
import { cloneDeep } from '~/lib/lodash'
import { apiClient } from '~/lib/request'
import { routeBuilder, Routes } from '~/lib/route-builder'
import { toast } from '~/lib/toast'

import { defineQuery } from '../helper'
Expand All @@ -14,12 +13,7 @@ export const post = {
bySlug: (category: string, slug: string) =>
defineQuery({
queryKey: ['post', category, slug],
meta: {
hydrationRoutePath: routeBuilder(Routes.Post, {
category,
slug,
}),
},

queryFn: async ({ queryKey }) => {
const [, category, slug] = queryKey

Expand Down

0 comments on commit 6031d85

Please sign in to comment.