From a5cbf519beb3e74623251b310a11abd55897b973 Mon Sep 17 00:00:00 2001 From: Yuriy Matskanyuk Date: Wed, 18 Mar 2026 23:33:52 +0500 Subject: [PATCH] feat: Visible refresh status --- internal/commands/list.go | 26 +++++++++++++++++++++++--- internal/commands/tui.go | 1 + 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/internal/commands/list.go b/internal/commands/list.go index f7fbe2e..da29a1d 100644 --- a/internal/commands/list.go +++ b/internal/commands/list.go @@ -111,6 +111,11 @@ func sortList(m model) func() tea.Msg { } } +type refreshDone struct { + items []list.Item + errors []string +} + func refreshList(m model) func() tea.Msg { return func() tea.Msg { var errorItems []ErrorItem @@ -141,10 +146,9 @@ func refreshList(m model) func() tea.Msg { es = append(es, fmt.Sprintf("Error fetching %s: %s", e.FeedURL, e.Err)) } - m.errors = es - return listUpdate{ + return refreshDone{ items: convertItems(items), - status: "Refreshed.", + errors: es, } } } @@ -167,6 +171,15 @@ func updateList(msg tea.Msg, m model) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case statusUpdate: cmds = append(cmds, m.list.NewStatusMessage(msg.status)) + case refreshDone: + m.refreshing = false + m.list.Title = defaultTitle + m.list.Styles.Title = m.list.Styles.Title.Width(lipgloss.Width(defaultTitle) + 2) + if !m.list.SettingFilter() { + m.list.SetItems(msg.items) + } + m.errors = msg.errors + cmds = append(cmds, m.list.NewStatusMessage("Refreshed.")) case listUpdate: if m.list.SettingFilter() { break @@ -192,6 +205,13 @@ func updateList(msg tea.Msg, m model) (tea.Model, tea.Cmd) { break } + if m.refreshing { + break + } + + m.refreshing = true + m.list.Title = "Refreshing..." + m.list.Styles.Title = m.list.Styles.Title.Width(lipgloss.Width("Refreshing...") + 2) cmds = append(cmds, refreshList(m)) case key.Matches(msg, ListKeyMap.Read): diff --git a/internal/commands/tui.go b/internal/commands/tui.go index 43cbd56..7ed0ebe 100644 --- a/internal/commands/tui.go +++ b/internal/commands/tui.go @@ -52,6 +52,7 @@ type model struct { viewport viewport.Model lastRead *list.Item lastReadIndex int + refreshing bool } func (m model) Init() tea.Cmd {