Library: the text filter only acts on the focused list

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 21:00:56 +02:00
co-authored by Claude Sonnet 5.5
parent cd4e3b8841
commit b0a2c3b4fd
3 changed files with 15 additions and 8 deletions
+11 -5
View File
@@ -182,7 +182,8 @@ type libPane struct {
shown []libItem
loaded bool
err error
gen int // invalidates stale loads
gen int // invalidates stale loads
text string // text filter, set with / while this pane is the current one
}
// libraryView shows the movies of Radarr above the series of Sonarr, with the
@@ -222,7 +223,7 @@ func newLibraryView(app *App, r *radarr.Client, s *sonarr.Client) *libraryView {
v := &libraryView{
app: app, radarr: r, sonarr: s,
header: tview.NewTextView().SetDynamicColors(true),
input: tview.NewInputField().SetLabel("Filter: ").SetFieldWidth(0),
input: tview.NewInputField().SetLabel("Filter Movies: ").SetFieldWidth(0),
details: tview.NewTextView().SetDynamicColors(true).SetWordWrap(true),
seriesFiles: map[int]seriesFiles{},
@@ -238,6 +239,8 @@ func newLibraryView(app *App, r *radarr.Client, s *sonarr.Client) *libraryView {
p.table.SetInputCapture(v.handleKey)
p.table.SetFocusFunc(func() {
v.cur = kind
v.input.SetLabel("Filter " + kind.String() + ": ")
v.input.SetText(p.text)
p.table.SetBorderColor(tcell.ColorYellow)
v.renderDetails()
})
@@ -252,7 +255,10 @@ func newLibraryView(app *App, r *radarr.Client, s *sonarr.Client) *libraryView {
AddItem(lists, 0, 3, true).
AddItem(v.details, 0, 2, false), 0, 1, true)
v.input.SetChangedFunc(func(string) { v.render() })
v.input.SetChangedFunc(func(text string) {
v.pane().text = text // the text filter only acts on the current pane
v.render()
})
v.input.SetDoneFunc(func(tcell.Key) { v.app.app.SetFocus(v.pane().table) })
v.render()
return v
@@ -381,7 +387,7 @@ func (v *libraryView) renderPane(p *libPane) {
if r, _ := p.table.GetSelection(); r >= 1 && r <= len(p.shown) {
selID = p.shown[r-1].id
}
p.shown = filterItems(p.all, v.filter, v.input.GetText(), v.attr)
p.shown = filterItems(p.all, v.filter, p.text, v.attr)
p.table.Clear()
header(p.table, 0, "Title", "Status", "Size")
@@ -511,7 +517,7 @@ func (v *libraryView) openFilterDialog() {
func (v *libraryView) filterPool() filterPool {
var p filterPool
for _, pane := range v.panes {
for _, it := range filterItems(pane.all, v.filter, v.input.GetText(), attrFilter{}) {
for _, it := range filterItems(pane.all, v.filter, pane.text, attrFilter{}) {
if !it.attrsKnown {
p.unknown = true
}