diff --git a/CHANGELOG.md b/CHANGELOG.md index cfa5d11..3f87bb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- **After a grab** the release list closes and you are back where the search started. - **Season posters** in the series drill-down: a season and its episodes show the season's poster (from TheTVDB, via Sonarr), the series poster where a season has none or it cannot be loaded. - **Cast in the details pane:** with a Trakt client ID, the details of a movie or series list its diff --git a/internal/ui/app.go b/internal/ui/app.go index a9db2d8..a4d448a 100644 --- a/internal/ui/app.go +++ b/internal/ui/app.go @@ -101,6 +101,7 @@ var serviceNames = []string{"Radarr", "Sonarr", "SABnzbd"} // hints replaces the view's key hints in the status bar while it is open. type overlay struct { page string + root tview.Primitive // what was pushed focus tview.Primitive hints string full bool // full-screen view (can be left with F1-F7), as opposed to a dialog @@ -527,7 +528,7 @@ func (a *App) renderStatus() { // pushOverlay stacks p above everything and focuses focus. func (a *App) pushOverlay(p, focus tview.Primitive, hints string, full bool, onClose func()) { name := fmt.Sprintf("overlay-%d", len(a.overlays)) - a.overlays = append(a.overlays, overlay{page: name, focus: a.app.GetFocus(), hints: hints, full: full, close: onClose}) + a.overlays = append(a.overlays, overlay{page: name, root: p, focus: a.app.GetFocus(), hints: hints, full: full, close: onClose}) a.pages.AddPage(name, p, true, true) a.app.SetFocus(focus) a.renderStatus() @@ -566,6 +567,14 @@ func (a *App) openFull(p tview.Primitive, hints string, onClose func()) { a.pushOverlay(p, p, hints, true, onClose) } +// closeIfTop closes the topmost overlay if it is p (and not something opened +// on top of it since). +func (a *App) closeIfTop(p tview.Primitive) { + if n := len(a.overlays); n > 0 && a.overlays[n-1].root == p { + a.closeModal() + } +} + // closeModal removes the topmost overlay and restores the previous focus. func (a *App) closeModal() { if len(a.overlays) == 0 { diff --git a/internal/ui/releases.go b/internal/ui/releases.go index faec334..937a2f8 100644 --- a/internal/ui/releases.go +++ b/internal/ui/releases.go @@ -269,6 +269,7 @@ func (v *releasesView) doGrab(r arr.Release) { return } v.app.SetMessage("[green]Sent to the download client: " + tview.Escape(truncate(r.Title, 60))) + v.app.closeIfTop(v.root) // done here: back to where the search started }) }() }