Skip to content

Commit

Permalink
fix(agent): 🐛 fix registration flow from changes in 7591c7a
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuar committed Dec 27, 2024
1 parent 1e9d3c9 commit 70176ce
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/agent/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func checkRegistration(ctx context.Context, agentUI ui) error {
}

// If not headless, present a UI for the user to configure options.
if options.headless {
if !options.headless {
userInputDoneCh := agentUI.DisplayRegistrationWindow(ctx, registrationOptions)
if canceled := <-userInputDoneCh; canceled {
return ErrUserCancelledRegistration
Expand All @@ -43,12 +43,15 @@ func checkRegistration(ctx context.Context, agentUI ui) error {
if err != nil {
return fmt.Errorf("device registration failed: %w", err)
}

// Save the returned preferences.
if err := preferences.SetHassPreferences(registrationDetails, registrationOptions); err != nil {
return fmt.Errorf("saving registration failed: %w", err)
}

// Set registration status.
if err := preferences.SetRegistered(true); err != nil {
return fmt.Errorf("saving registration failed: %w", err)
}
// Save preferences to disk.
if err := preferences.Save(); err != nil {
return fmt.Errorf("saving registration failed: %w", err)
}
Expand Down

0 comments on commit 70176ce

Please sign in to comment.