From 7b8af99181cda77f7c1f9a10efe717040dbe507c Mon Sep 17 00:00:00 2001 From: oddgrd Date: Fri, 18 Feb 2022 22:15:11 +0100 Subject: [PATCH] Fix missing query param error, spinner DOM error --- .../{src/assets/images => public}/Loading.svg | 0 client/src/components/Spinner.tsx | 9 +++- client/src/pages/board/[id].tsx | 2 + .../boards/[id]/create-problem/index.tsx | 1 + client/src/pages/boards/[id]/index.tsx | 46 ++++++++----------- client/src/pages/problem/[id].tsx | 1 + client/src/pages/profile/[id].tsx | 3 ++ 7 files changed, 33 insertions(+), 29 deletions(-) rename client/{src/assets/images => public}/Loading.svg (100%) diff --git a/client/src/assets/images/Loading.svg b/client/public/Loading.svg similarity index 100% rename from client/src/assets/images/Loading.svg rename to client/public/Loading.svg diff --git a/client/src/components/Spinner.tsx b/client/src/components/Spinner.tsx index ea3a8c4..7a4776f 100644 --- a/client/src/components/Spinner.tsx +++ b/client/src/components/Spinner.tsx @@ -1,10 +1,15 @@ import Image from 'next/image'; -import spinner from '../assets/images/Loading.svg'; export const Spinner = () => { return (
- +
); }; diff --git a/client/src/pages/board/[id].tsx b/client/src/pages/board/[id].tsx index a82e1d5..59415d6 100644 --- a/client/src/pages/board/[id].tsx +++ b/client/src/pages/board/[id].tsx @@ -34,9 +34,11 @@ const Board = () => { const boardId = typeof router.query.id === 'string' ? router.query.id : ''; const { data, loading, error } = useGetBoardQuery({ variables: { boardId }, + skip: !router.isReady, }); const { data: layoutData } = useGetBoardLayoutsQuery({ variables: { boardId }, + skip: !router.isReady, }); if (error) { diff --git a/client/src/pages/boards/[id]/create-problem/index.tsx b/client/src/pages/boards/[id]/create-problem/index.tsx index fe196bc..c0c4ce2 100644 --- a/client/src/pages/boards/[id]/create-problem/index.tsx +++ b/client/src/pages/boards/[id]/create-problem/index.tsx @@ -25,6 +25,7 @@ const CreateProblem = () => { useIsWhitelisted(boardId); const { data, loading } = useGetBoardQuery({ variables: { boardId }, + skip: !router.isReady, }); useEffect(() => { diff --git a/client/src/pages/boards/[id]/index.tsx b/client/src/pages/boards/[id]/index.tsx index 378236c..a91b5f8 100644 --- a/client/src/pages/boards/[id]/index.tsx +++ b/client/src/pages/boards/[id]/index.tsx @@ -46,16 +46,11 @@ const Problems = () => { const { data: meData } = useMeQuery(); - const { - data: boardData, - loading: boardLoading, - error: boardError, - } = useGetBoardQuery({ + const { data: boardData, error: boardError } = useGetBoardQuery({ variables: { boardId, }, skip: !router.isReady, - notifyOnNetworkStatusChange: true, }); const { ref, inView } = useInView({ @@ -114,14 +109,6 @@ const Problems = () => { ); } - if (boardLoading && !boardData) { - return ( - - - - ); - } - if (boardData && !boardData?.getBoard.currentLayout) { return ( @@ -150,16 +137,17 @@ const Problems = () => { > - - - - - - + {router.isReady && ( + + + + + + )} } > @@ -184,9 +172,13 @@ const Problems = () => { data?.getProblems.problems.length === 0 && searchPattern.length === 0 ? (
- - Create First Problem - + {router.isReady ? ( + + Create First Problem + + ) : ( +

No problems found

+ )}
) : data?.getProblems.problems.length === 0 && searchPattern.length !== 0 ? ( diff --git a/client/src/pages/problem/[id].tsx b/client/src/pages/problem/[id].tsx index c46a15b..63a50bd 100644 --- a/client/src/pages/problem/[id].tsx +++ b/client/src/pages/problem/[id].tsx @@ -33,6 +33,7 @@ const Problem = () => { id: problemId, }, fetchPolicy: 'cache-and-network', + skip: !router.isReady, }); useEffect(() => { diff --git a/client/src/pages/profile/[id].tsx b/client/src/pages/profile/[id].tsx index 5405d17..989e2ed 100644 --- a/client/src/pages/profile/[id].tsx +++ b/client/src/pages/profile/[id].tsx @@ -19,11 +19,14 @@ const Profile = () => { const { data, loading } = useGetUserQuery({ variables: { id: profileId }, + fetchPolicy: 'cache-and-network', + skip: !router.isReady, }); const { data: sendData, loading: sendLoading } = useGetSentProblemsQuery({ variables: { userId: profileId }, fetchPolicy: 'cache-and-network', + skip: !router.isReady, }); const ascentGrades = useMemo(() => {