From 740f70ab37bcf8fb3b99e2087375a6cd5a75e6c0 Mon Sep 17 00:00:00 2001 From: Drew Smirnoff Date: Thu, 29 Jan 2026 00:50:35 +0400 Subject: [PATCH] ui: remove the double email counts (eye sore) (#126) --- tui/inbox.go | 12 ++++-------- tui/inbox_test.go | 36 ------------------------------------ 2 files changed, 4 insertions(+), 44 deletions(-) diff --git a/tui/inbox.go b/tui/inbox.go index 29f267e0d75af2fa89f6624c68ab2828da8119d2..f7620c906766c894b190b3101a0302bea4335d67 100644 --- a/tui/inbox.go +++ b/tui/inbox.go @@ -219,15 +219,15 @@ func (m *Inbox) updateList() { func (m *Inbox) getTitle() string { var title string if m.currentAccountID == "" { - title = m.getBaseTitleWithCount() + " - All Accounts" + title = m.getBaseTitle() + " - All Accounts" } else { - title = m.getBaseTitleWithCount() + title = m.getBaseTitle() for _, acc := range m.accounts { if acc.ID == m.currentAccountID { if acc.Name != "" { - title = fmt.Sprintf("%s - %s", m.getBaseTitleWithCount(), acc.Name) + title = fmt.Sprintf("%s - %s", m.getBaseTitle(), acc.Name) } else { - title = fmt.Sprintf("%s - %s", m.getBaseTitleWithCount(), acc.Email) + title = fmt.Sprintf("%s - %s", m.getBaseTitle(), acc.Email) } break } @@ -251,10 +251,6 @@ func (m *Inbox) getBaseTitle() string { } } -func (m *Inbox) getBaseTitleWithCount() string { - return fmt.Sprintf("%s (%d)", m.getBaseTitle(), m.emailsCount) -} - func (m *Inbox) Init() tea.Cmd { return nil } diff --git a/tui/inbox_test.go b/tui/inbox_test.go index ce18d032dadc5a1ada31d734ea1e9cb8c1103757..9f8ce4d2c4a6a66ab1ff529192e8af4fa62a0fde 100644 --- a/tui/inbox_test.go +++ b/tui/inbox_test.go @@ -1,7 +1,6 @@ package tui import ( - "strings" "testing" "time" @@ -272,41 +271,6 @@ func TestInboxGetEmailAtIndex(t *testing.T) { } } -func TestInboxTitleShowsCount(t *testing.T) { - accounts := []config.Account{ - {ID: "account-1", Email: "test@example.com"}, - } - - emails := []fetcher.Email{ - {UID: 1, From: "sender@example.com", Subject: "Email 1", AccountID: "account-1", Date: time.Now()}, - {UID: 2, From: "sender@example.com", Subject: "Email 2", AccountID: "account-1", Date: time.Now().Add(-time.Minute)}, - {UID: 3, From: "sender@example.com", Subject: "Email 3", AccountID: "account-1", Date: time.Now().Add(-2 * time.Minute)}, - } - - inbox := NewInbox(emails, accounts) - - if !strings.Contains(inbox.list.Title, "Inbox (3)") { - t.Fatalf("expected inbox title to contain count, got %q", inbox.list.Title) - } -} - -func TestSentInboxTitleShowsCount(t *testing.T) { - accounts := []config.Account{ - {ID: "account-1", Email: "test@example.com"}, - } - - emails := []fetcher.Email{ - {UID: 1, From: "sender@example.com", Subject: "Email 1", AccountID: "account-1", Date: time.Now()}, - {UID: 2, From: "sender@example.com", Subject: "Email 2", AccountID: "account-1", Date: time.Now().Add(-time.Minute)}, - } - - inbox := NewSentInbox(emails, accounts) - - if !strings.Contains(inbox.list.Title, "Sent (2)") { - t.Fatalf("expected sent title to contain count, got %q", inbox.list.Title) - } -} - func TestFetchMoreTriggeredAtListEnd(t *testing.T) { accounts := []config.Account{ {ID: "account-1", Email: "test@example.com"},