Fixed react query retry logic

This commit is contained in:
Atridad Lahiji 2023-10-15 00:44:21 -03:00 committed by atridadl
parent d1237d3b47
commit 1a6c31414e
No known key found for this signature in database

View file

@ -39,9 +39,14 @@ const VoteUI = () => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const { data: roomFromDb } = useQuery({ const {
data: roomFromDb,
isLoading: roomFromDbLoading,
isFetching: roomFromDbFetching,
} = useQuery({
queryKey: ["room"], queryKey: ["room"],
queryFn: getRoomHandler, queryFn: getRoomHandler,
retry: false,
}); });
const { data: votesFromDb } = useQuery({ const { data: votesFromDb } = useQuery({
@ -312,11 +317,11 @@ const VoteUI = () => {
// UI // UI
// ================================= // =================================
// Room is loading // Room is loading
if (roomFromDb === undefined) { if (roomFromDbLoading || roomFromDbFetching) {
return <LoadingIndicator />; return <LoadingIndicator />;
// Room has been loaded // Room has been loaded
} else if (roomFromDb) { } else {
return ( return roomFromDb ? (
<div className="flex flex-col gap-4 text-center justify-center items-center"> <div className="flex flex-col gap-4 text-center justify-center items-center">
<div className="text-2xl">{roomFromDb.roomName}</div> <div className="text-2xl">{roomFromDb.roomName}</div>
<div className="flex flex-row flex-wrap text-center justify-center items-center gap-1 text-md"> <div className="flex flex-row flex-wrap text-center justify-center items-center gap-1 text-md">
@ -542,10 +547,9 @@ const VoteUI = () => {
</> </>
)} )}
</div> </div>
) : (
<NoRoomUI />
); );
// Room does not exist
} else {
return <NoRoomUI />;
} }
}; };