Skip to content

Commit

Permalink
fix: autopilot feature enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Apr 1, 2023
1 parent b4268df commit 3abd60c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-owls-check.md
@@ -0,0 +1,5 @@
---
'@siafoundation/renterd': minor
---

Autopilot feature is now enabled properly.
17 changes: 6 additions & 11 deletions apps/renterd/hooks/useAutopilot.tsx
@@ -1,13 +1,8 @@
import { useAutopilotHostsSearch } from '@siafoundation/react-core'
import { useAutopilotStatus } from '@siafoundation/react-core'
import { useEffect, useState } from 'react'

export function useAutopilot() {
const apr = useAutopilotHostsSearch({
payload: {
limit: 1,
offset: 0,
filterMode: 'all',
},
const aps = useAutopilotStatus({
config: {
swr: {
dedupingInterval: 60_000,
Expand All @@ -22,16 +17,16 @@ export function useAutopilot() {
)

useEffect(() => {
if (autopilotMode === 'init' && (apr.data || apr.error)) {
if (apr.error) {
if (autopilotMode === 'init' && (aps.data || aps.error)) {
if (aps.error) {
setAutopilotMode('off')
}
// This check is required because the API currently returns html when the endpoint does not exist
const validResponse = typeof apr.data === 'object'
const validResponse = typeof aps.data === 'object'
setAutopilotMode(validResponse ? 'on' : 'off')
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [apr])
}, [aps])

return {
autopilotMode,
Expand Down

0 comments on commit 3abd60c

Please sign in to comment.