From 5d6f5264e395ecdc5c00c5247fe1d7aae17187db Mon Sep 17 00:00:00 2001 From: mkbeefcake Date: Mon, 4 Sep 2023 12:51:31 +0000 Subject: [PATCH] 20230904: fix lint issue --- .../ui/src/app/providers/QueryNodeProvider.tsx | 16 ++++++++++------ .../ui/src/forum/hooks/useCategoryLatestPost.ts | 11 +++++------ .../ui/src/forum/hooks/useThreadLatestPost.ts | 11 ++++++----- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/packages/ui/src/app/providers/QueryNodeProvider.tsx b/packages/ui/src/app/providers/QueryNodeProvider.tsx index 962deeadfb..9f88e1c787 100644 --- a/packages/ui/src/app/providers/QueryNodeProvider.tsx +++ b/packages/ui/src/app/providers/QueryNodeProvider.tsx @@ -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' @@ -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) { @@ -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, diff --git a/packages/ui/src/forum/hooks/useCategoryLatestPost.ts b/packages/ui/src/forum/hooks/useCategoryLatestPost.ts index cfee13ccf4..5d03cab8fc 100644 --- a/packages/ui/src/forum/hooks/useCategoryLatestPost.ts +++ b/packages/ui/src/forum/hooks/useCategoryLatestPost.ts @@ -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: { @@ -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] diff --git a/packages/ui/src/forum/hooks/useThreadLatestPost.ts b/packages/ui/src/forum/hooks/useThreadLatestPost.ts index 7a082d8ec8..a07c754f1c 100644 --- a/packages/ui/src/forum/hooks/useThreadLatestPost.ts +++ b/packages/ui/src/forum/hooks/useThreadLatestPost.ts @@ -1,10 +1,8 @@ +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] @@ -12,7 +10,10 @@ 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) } }