-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
20230904: integrated persist storage for cache
- Loading branch information
1 parent
324f845
commit fab07d6
Showing
5 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import { useMemo } from 'react' | ||
|
||
import { GetForumPostsDocument } from '@/forum/queries' | ||
import * as Apollo from '@apollo/client' | ||
import { ForumPostOrderByInput, ForumPostWhereInput } from '@/common/api/queries' | ||
import { useGetForumPostsQuery } from '@/forum/queries' | ||
|
||
import { asForumPost } from '@/forum/types' | ||
|
||
const orderBy = [ForumPostOrderByInput.UpdatedAtDesc] | ||
|
||
export const useThreadLatestPost = (threadId: string) => { | ||
const where = useMemo((): ForumPostWhereInput => ({ thread: { id_eq: threadId }, isVisible_eq: true }), [threadId]) | ||
const { data } = useGetForumPostsQuery({ variables: { where, orderBy, limit: 1 } }) | ||
// const { data } = useGetForumPostsQuery({ variables: { where, orderBy, limit: 1 } }) | ||
const { data } = Apollo.useQuery(GetForumPostsDocument, { variables: { where, orderBy, limit: 1 }, fetchPolicy:'cache-only'}); | ||
const rawPost = data?.forumPosts[0] | ||
return { post: rawPost && asForumPost(rawPost) } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters