Library: mark titles that are downloading
While the Library is visible it reads the Radarr and Sonarr queues (on opening, every 10 s, and shortly after a grab) and matches them to the titles by movieId / seriesId. Those titles get a blue dot instead of the green or grey one, and their details say how far the download is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+25
-2
@@ -67,6 +67,19 @@ var libFilters = []struct {
|
||||
{"unmonitored", func(i libItem) bool { return !i.monitored }},
|
||||
}
|
||||
|
||||
// libMark is the mark before a library title: blue while it is in the
|
||||
// download queue, else green when monitored; filled when monitored, hollow
|
||||
// when not.
|
||||
func libMark(monitored, downloading bool) string {
|
||||
if !downloading {
|
||||
return monMark(monitored)
|
||||
}
|
||||
if monitored {
|
||||
return "[blue]●[-]"
|
||||
}
|
||||
return "[blue]○[-]"
|
||||
}
|
||||
|
||||
func monMark(monitored bool) string {
|
||||
if monitored {
|
||||
return "[green]●[-]"
|
||||
@@ -215,6 +228,10 @@ type libraryView struct {
|
||||
filePending int
|
||||
|
||||
refreshDialog func() // re-evaluates the options of the open filter dialog
|
||||
|
||||
// Titles in the Radarr/Sonarr download queue, by kind and id (libqueue.go).
|
||||
downloading [2]map[int]dlInfo
|
||||
queueStop chan struct{}
|
||||
}
|
||||
|
||||
type seriesFiles struct {
|
||||
@@ -317,6 +334,7 @@ func (v *libraryView) activate() {
|
||||
v.app.app.SetFocus(v.pane().table)
|
||||
v.render()
|
||||
v.reload()
|
||||
v.startQueueWatch()
|
||||
}
|
||||
|
||||
// reload fetches both lists in parallel.
|
||||
@@ -404,7 +422,8 @@ func (v *libraryView) renderPane(p *libPane) {
|
||||
header(p.table, 0, "Title", "Status", "Size")
|
||||
selRow := 0
|
||||
for i, it := range p.shown {
|
||||
title := titleCell{prefix: monMark(it.monitored) + " ", title: it.label}
|
||||
_, dl := v.downloading[p.kind][it.id]
|
||||
title := titleCell{prefix: libMark(it.monitored, dl) + " ", title: it.label}
|
||||
p.table.SetCell(i+1, 0, tview.NewTableCell(title.fit(0)).SetExpansion(1).SetReference(title))
|
||||
p.table.SetCell(i+1, 1, tview.NewTableCell(it.status))
|
||||
p.table.SetCell(i+1, 2, tview.NewTableCell(it.size).SetAlign(tview.AlignRight))
|
||||
@@ -532,7 +551,11 @@ func containsItem(items []libItem, id int) bool {
|
||||
|
||||
func (v *libraryView) renderDetails() {
|
||||
if it, ok := v.selected(); ok {
|
||||
v.details.Show(it.details, it.cover)
|
||||
d := it.details
|
||||
if dl, ok := v.downloading[v.cur][it.id]; ok {
|
||||
d.head += dl.dlLine()
|
||||
}
|
||||
v.details.Show(d, it.cover)
|
||||
return
|
||||
}
|
||||
v.details.Clear()
|
||||
|
||||
Reference in New Issue
Block a user