Skip to content

Commit

Permalink
fix setting env to none
Browse files Browse the repository at this point in the history
  • Loading branch information
mirzakhany committed Aug 24, 2024
1 parent a9ff428 commit 9652970
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ui/app/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ func (h *Header) Layout(gtx layout.Context, theme *chapartheme.Theme) layout.Dim
}
} else {
h.envState.ClearActiveEnvironment()
if h.OnSelectedEnvChanged != nil {
if err := h.OnSelectedEnvChanged(nil); err != nil {
h.showError(err)
}
}
}
}

Expand Down
17 changes: 14 additions & 3 deletions ui/app/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,24 @@ func New(w *app.Window) (*UI, error) {
return fmt.Errorf("failed to read preferences, %w", err)
}

preferences.Spec.SelectedEnvironment.ID = env.MetaData.ID
preferences.Spec.SelectedEnvironment.Name = env.MetaData.Name
if env != nil {
preferences.Spec.SelectedEnvironment.ID = env.MetaData.ID
preferences.Spec.SelectedEnvironment.Name = env.MetaData.Name
} else {
preferences.Spec.SelectedEnvironment.ID = ""
preferences.Spec.SelectedEnvironment.Name = ""
}

if err := repo.UpdatePreferences(preferences); err != nil {
return fmt.Errorf("failed to update preferences, %w", err)
}

u.environmentsState.SetActiveEnvironment(env)
if env != nil {
u.environmentsState.SetActiveEnvironment(env)
} else {
u.environmentsState.ClearActiveEnvironment()
}

return nil
}

Expand Down

0 comments on commit 9652970

Please sign in to comment.