Fix isLoading state initialization and add delay before refreshing
This commit is contained in:
parent
18fd6c1814
commit
4421c8154d
2 changed files with 10 additions and 4 deletions
|
|
@ -69,7 +69,6 @@ export default function ParameterComponent({
|
|||
const nodes = useFlowStore((state) => state.nodes);
|
||||
const edges = useFlowStore((state) => state.edges);
|
||||
const setNode = useFlowStore((state) => state.setNode);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const flow = currentFlow?.data?.nodes ?? null;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,13 +13,20 @@ function RefreshButton({
|
|||
}) {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const handleClick = () => {
|
||||
const handleClick = async () => {
|
||||
setIsLoading(true);
|
||||
console.log("refreshing");
|
||||
handleUpdateValues(name, data);
|
||||
setInterval(() => {
|
||||
try {
|
||||
// Wait for at least 500 milliseconds
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
// Continue with the request
|
||||
// If the request takes longer than 500 milliseconds, it will not wait an additional 500 milliseconds
|
||||
} catch (error) {
|
||||
console.error("Error occurred while waiting for refresh:", error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}, 500);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue