Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid page flickering on pod completion #24

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions frontend/src/api/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ export function useApiSubscription <T extends {}, Args extends unknown[]> (
const { url, method, body } = route.request(...args)

const { fetch, reset } = fetcher

// Start with empty data and error initially, and every time the arguments change.
useEffect(() => {
// This effect hook is called once initially, and then every time the arguments change.
// As such, we want to start with empty data and error.
reset()
}, [reset, route, url, method, body])

// Subscribe to the route.
useEffect(() => {
// Prevent subscriptions to non-nilpotent routes.
if (method != null && method !== 'GET') {
return
Expand All @@ -48,7 +52,7 @@ export function useApiSubscription <T extends {}, Args extends unknown[]> (
abortController?.abort()
clearInterval(interval)
}
}, [fetch, reset, options.interval, route, url, method, body])
}, [fetch, options.interval, route, url, method, body])

const loading = fetcher.data == null && fetcher.error == null

Expand Down