Skip to content

Commit

Permalink
improved logic
Browse files Browse the repository at this point in the history
  • Loading branch information
bekossy committed May 20, 2024
1 parent 78e9452 commit d0fc13a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions agenta-web/src/components/Playground/ViewNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const ViewNavigation: React.FC<Props> = ({
const [isDrawerOpen, setIsDrawerOpen] = useState(false)
const stopperRef = useRef<Function | null>(null)
const [isDelayed, setIsDelayed] = useState(false)
const [loading, setLoading] = useState(false)

let prevKey = ""
const showNotification = (config: Parameters<typeof notification.open>[0]) => {
Expand Down Expand Up @@ -136,15 +137,16 @@ const ViewNavigation: React.FC<Props> = ({
}, [netWorkError, isError, variant.variantId])

useEffect(() => {
if (retrying) {
if (retrying && variantErrorLogs) {
const timeout = setTimeout(() => {
setIsDelayed(true)
}, 6000)
return () => clearTimeout(timeout)
}
}, [retrying])
}, [retrying, variantErrorLogs])

const handleStopPolling = () => {
setLoading(true)
if (stopperRef.current) {
stopperRef.current()
}
Expand All @@ -161,7 +163,7 @@ const ViewNavigation: React.FC<Props> = ({
title="This is taking longer than expected"
spinner={retrying}
/>
<Button onClick={handleStopPolling} type="primary">
<Button loading={loading} onClick={handleStopPolling} type="primary">
Show Logs
</Button>
</div>
Expand Down

0 comments on commit d0fc13a

Please sign in to comment.