First start: create the config file and open the Config view
Without a config file arr-tui refused to start. It now creates an empty one (private, with its directory) and opens the Config view. A service with neither address nor key is "not configured", which validation allows: its client returns ErrNotConfigured without a request, its indicator stays grey, it is logged once as information, and its lists say so instead of showing errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019reK4DUGYqDUjniWYJvwUW
This commit is contained in:
@@ -35,6 +35,7 @@ type downloadsView struct {
|
||||
sab *sabnzbd.Client
|
||||
sources []arrSource
|
||||
interval time.Duration
|
||||
sabUnset bool // SABnzbd is not set up: its lists say so instead of "empty"
|
||||
|
||||
root *tview.Flex
|
||||
summary *tview.TextView
|
||||
@@ -210,6 +211,12 @@ func (v *downloadsView) refresh(ctx context.Context) {
|
||||
|
||||
v.app.post(func() {
|
||||
v.app.SetService("SABnzbd", "", qerr)
|
||||
if unset := notConfigured(qerr); unset != v.sabUnset {
|
||||
v.sabUnset = unset
|
||||
v.sabQueue, v.slots, v.done = sabnzbd.Queue{}, nil, nil
|
||||
v.renderQueue()
|
||||
v.renderHistory()
|
||||
}
|
||||
if qerr == nil {
|
||||
v.sabQueue, v.slots, v.paused = queue, queue.Slots, queue.Paused
|
||||
v.renderQueue()
|
||||
@@ -230,6 +237,14 @@ func (v *downloadsView) refresh(ctx context.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// sabPlaceholder is what an empty SABnzbd list says.
|
||||
func (v *downloadsView) sabPlaceholder(empty string) string {
|
||||
if v.sabUnset {
|
||||
return "SABnzbd is not configured (Config view, F6)"
|
||||
}
|
||||
return empty
|
||||
}
|
||||
|
||||
func (v *downloadsView) rebuildArrRows() {
|
||||
v.arrRows = v.arrRows[:0]
|
||||
for _, s := range v.sources {
|
||||
@@ -331,7 +346,7 @@ func (v *downloadsView) renderQueue() {
|
||||
}
|
||||
}
|
||||
fill(v.queue, 0, rows)
|
||||
restoreSelection(v.queue, len(rows), selRow, "Queue is empty")
|
||||
restoreSelection(v.queue, len(rows), selRow, v.sabPlaceholder("Queue is empty"))
|
||||
}
|
||||
|
||||
func (v *downloadsView) renderArr() {
|
||||
@@ -414,7 +429,7 @@ func (v *downloadsView) renderHistory() {
|
||||
}
|
||||
}
|
||||
fill(v.history, 0, rows)
|
||||
restoreSelection(v.history, len(rows), selRow, "No history")
|
||||
restoreSelection(v.history, len(rows), selRow, v.sabPlaceholder("No history"))
|
||||
}
|
||||
|
||||
// act runs an action off the UI goroutine, reports the outcome and refreshes.
|
||||
|
||||
Reference in New Issue
Block a user