diff --git a/main.go b/main.go index 41c308ee7e7df78f38416b52cf2741d357f5a689..b97b4200c131b6022043d856ebea1476594a118a 100644 --- a/main.go +++ b/main.go @@ -408,7 +408,7 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if msg.FolderName != "" && m.config != nil { delete(m.folderEmails, msg.FolderName) if m.folderInbox != nil { - m.folderInbox.SetLoadingEmails(true) + m.folderInbox.SetRefreshing(true) } return m, fetchFolderEmailsCmd(m.config, msg.FolderName) } diff --git a/tui/folder_inbox.go b/tui/folder_inbox.go index 5e5042d123631f178653f1b95ca256ecb1d98f24..5d9145422962446bbfbe165c95db230876ec95ef 100644 --- a/tui/folder_inbox.go +++ b/tui/folder_inbox.go @@ -178,6 +178,8 @@ func (m *FolderInbox) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil } m.isLoadingEmails = false + m.inbox.isFetching = false + m.inbox.isRefreshing = false m.inbox.SetEmails(msg.Emails, m.accounts) m.inbox.SetFolderName(msg.FolderName) return m, nil @@ -501,8 +503,16 @@ func (m *FolderInbox) SetLoadingEmails(loading bool) { m.isLoadingEmails = loading if loading { m.inbox.isFetching = true - m.inbox.list.Title = m.inbox.getTitle() + } else { + m.inbox.isFetching = false } + m.inbox.list.Title = m.inbox.getTitle() +} + +// SetRefreshing sets the refreshing state (used when user presses "r"). +func (m *FolderInbox) SetRefreshing(refreshing bool) { + m.inbox.isRefreshing = refreshing + m.inbox.list.Title = m.inbox.getTitle() } // GetFolders returns the current folder list. diff --git a/tui/inbox.go b/tui/inbox.go index a16dfd6222fc6d3cf373c2f16f67dc464a16510c..7e1ef7eefe5b7736bfb80b8b24dfe8c1e41e11ac 100644 --- a/tui/inbox.go +++ b/tui/inbox.go @@ -449,6 +449,8 @@ func (m *Inbox) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } } case "r": + m.isRefreshing = true + m.list.Title = m.getTitle() // Copy counts to avoid race conditions if used elsewhere (though here it's just passing data) counts := make(map[string]int) for k, v := range m.emailCountByAcct { @@ -539,7 +541,7 @@ func (m *Inbox) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } func (m *Inbox) shouldFetchMore() bool { - if m.isFetching { + if m.isFetching || m.isRefreshing { return false } if m.allAccountsExhausted() {