Skip to content

Commit

Permalink
20230904: fix lint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mkbeefcake committed Sep 4, 2023
1 parent fab07d6 commit 5d6f526
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
16 changes: 10 additions & 6 deletions packages/ui/src/app/providers/QueryNodeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
NormalizedCacheObject,
split,
} from '@apollo/client'
import { persistCache, LocalStorageWrapper } from 'apollo3-cache-persist'
import { onError } from '@apollo/client/link/error'
import { WebSocketLink } from '@apollo/client/link/ws'
import { getMainDefinition } from '@apollo/client/utilities'
import { persistCache, LocalStorageWrapper } from 'apollo3-cache-persist'
import React, { ReactNode, useEffect, useState } from 'react'

import { useApi } from '@/api/hooks/useApi'
Expand All @@ -35,10 +35,14 @@ export const QueryNodeProvider = ({ children }: Props) => {
useEffect(() => {
async function init() {
setApolloClient(
await getApolloClient(endpoints.queryNodeEndpoint, endpoints.queryNodeEndpointSubscription, setQnConnectionState)
await getApolloClient(
endpoints.queryNodeEndpoint,
endpoints.queryNodeEndpointSubscription,
setQnConnectionState
)
)
}
init();
init()
}, [endpoints.queryNodeEndpointSubscription, endpoints.queryNodeEndpoint])

if (!apolloClient) {
Expand Down Expand Up @@ -103,11 +107,11 @@ const getApolloClient = async (
queryLink
)

const cache = new InMemoryCache();
const cache = new InMemoryCache()
await persistCache({
cache,
storage: new LocalStorageWrapper(window.localStorage)
});
storage: new LocalStorageWrapper(window.localStorage),
})

return new ApolloClient({
link: splitLink,
Expand Down
11 changes: 5 additions & 6 deletions packages/ui/src/forum/hooks/useCategoryLatestPost.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import * as Apollo from '@apollo/client'
import { useEffect } from 'react'

import { ForumPostOrderByInput, ForumThreadOrderByInput } from '@/common/api/queries'
import { useGetForumPostsLazyQuery, useGetForumThreadsQuery } from '@/forum/queries'
import { useGetForumPostsLazyQuery, useGetForumThreadsQuery, GetForumPostsDocument } from '@/forum/queries'
import { asForumPost, asForumThread } from '@/forum/types'

import { GetForumPostsDocument } from '@/forum/queries'
import * as Apollo from '@apollo/client'

export const useCategoryLatestPost = (category_eq: string) => {
const { data: threadData, loading: loadingThreads } = useGetForumThreadsQuery({
variables: {
Expand All @@ -29,8 +27,9 @@ export const useCategoryLatestPost = (category_eq: string) => {
}, [threadData])

// const [fetchPost, { data: postData, loading: loadingPosts }] = useGetForumPostsLazyQuery()
const [fetchPost, { data: postData, loading: loadingPosts }] =
Apollo.useLazyQuery(GetForumPostsDocument, {fetchPolicy: 'cache-only'});
const [fetchPost, { data: postData, loading: loadingPosts }] = Apollo.useLazyQuery(GetForumPostsDocument, {
fetchPolicy: 'cache-only',
})

const rawPost = postData?.forumPosts[0]

Expand Down
11 changes: 6 additions & 5 deletions packages/ui/src/forum/hooks/useThreadLatestPost.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import * as Apollo from '@apollo/client'
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 { GetForumPostsDocument, 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 } = Apollo.useQuery(GetForumPostsDocument, { variables: { where, orderBy, limit: 1 }, fetchPolicy:'cache-only'});
const { data } = Apollo.useQuery(GetForumPostsDocument, {
variables: { where, orderBy, limit: 1 },
fetchPolicy: 'cache-only',
})
const rawPost = data?.forumPosts[0]
return { post: rawPost && asForumPost(rawPost) }
}

0 comments on commit 5d6f526

Please sign in to comment.