Skip to content

Commit

Permalink
make it work
Browse files Browse the repository at this point in the history
  • Loading branch information
13bfrancis committed Mar 26, 2024
1 parent dacca3a commit 12ca146
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/services/ui/src/hooks/useSyncStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getItem } from "@/api";
import { Route } from "@/components/Routing";
import { useNavigate } from "react-router-dom";
import { useQuery } from "@tanstack/react-query";
import { useState } from "react";
import { createRef, useRef, useState } from "react";
import { type SEATOOL_STATUS } from "shared-types";
import { queryClient } from "@/router";
import { ItemResult } from "shared-types/opensearch/main";
Expand All @@ -19,8 +19,10 @@ export const useSyncStatus = ({
const navigate = useNavigate();
const [runQuery, setRunQuery] = useState(false);
const [id, setId] = useState("");
const uniqueQueryId = useRef(Math.random());

useQuery({
queryKey: ["polling", id, uniqueQueryId],
queryFn: async () => {
try {
return await getItem(id);
Expand All @@ -43,7 +45,7 @@ export const useSyncStatus = ({
}

// otherwise try again in one second
return 500; //aka 1 second
return 1000; //aka 1 second
},
enabled: runQuery,
});
Expand Down

0 comments on commit 12ca146

Please sign in to comment.