Add the Config view: edit and save the settings, applied without a restart
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+20
-5
@@ -25,7 +25,6 @@ const (
|
||||
type searchView struct {
|
||||
app *App
|
||||
be backend
|
||||
cfg config.Arr
|
||||
|
||||
root *tview.Flex
|
||||
input *tview.InputField
|
||||
@@ -46,11 +45,10 @@ type searchView struct {
|
||||
loaded bool
|
||||
}
|
||||
|
||||
func newSearchView(app *App, be backend, cfg config.Arr) *searchView {
|
||||
func newSearchView(app *App, be backend) *searchView {
|
||||
v := &searchView{
|
||||
app: app,
|
||||
be: be,
|
||||
cfg: cfg,
|
||||
input: tview.NewInputField().SetLabel("Search: "),
|
||||
list: tview.NewList().ShowSecondaryText(false),
|
||||
details: newDetailPane(app),
|
||||
@@ -106,10 +104,27 @@ func newSearchView(app *App, be backend, cfg config.Arr) *searchView {
|
||||
return ev
|
||||
})
|
||||
|
||||
app.reconnect = append(app.reconnect, v.reloadOptions)
|
||||
go v.loadOptions()
|
||||
return v
|
||||
}
|
||||
|
||||
// defaults returns the add-form defaults of the service, as currently configured.
|
||||
func (v *searchView) defaults() config.Arr {
|
||||
if v.be.name() == "Radarr" {
|
||||
return v.app.cfg.Radarr
|
||||
}
|
||||
return v.app.cfg.Sonarr
|
||||
}
|
||||
|
||||
// reloadOptions fetches the profiles and folders again, after the service changed.
|
||||
func (v *searchView) reloadOptions() {
|
||||
v.mu.Lock()
|
||||
v.loaded = false
|
||||
v.mu.Unlock()
|
||||
go v.loadOptions()
|
||||
}
|
||||
|
||||
// loadOptions checks the connection and fetches the data the add form needs.
|
||||
func (v *searchView) loadOptions() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
@@ -301,8 +316,8 @@ func (v *searchView) add(i int) {
|
||||
lSearch = "Search now"
|
||||
)
|
||||
form := tview.NewForm().
|
||||
AddDropDown(lProfile, profileNames, profileIndex(profiles, v.cfg.DefaultQualityProfile), nil).
|
||||
AddDropDown(lFolder, folderPaths, folderIndex(folders, v.cfg.DefaultRootFolder), nil)
|
||||
AddDropDown(lProfile, profileNames, profileIndex(profiles, v.defaults().DefaultQualityProfile), nil).
|
||||
AddDropDown(lFolder, folderPaths, folderIndex(folders, v.defaults().DefaultRootFolder), nil)
|
||||
height := 13
|
||||
if len(modes) > 0 {
|
||||
form.AddDropDown(lEpisode, modeNames, 0, nil)
|
||||
|
||||
Reference in New Issue
Block a user