From 3198ab93f9787e6288411da4b98029569c53d084 Mon Sep 17 00:00:00 2001 From: Drew Smirnoff Date: Thu, 29 Jan 2026 00:50:54 +0400 Subject: [PATCH] fix: remove the tabs for a singular account usage (#125) --- tui/inbox.go | 30 +++++++++++++++++++----------- tui/inbox_test.go | 6 +++--- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/tui/inbox.go b/tui/inbox.go index f7620c906766c894b190b3101a0302bea4335d67..e9ac6861fc5d98b958d705c66107fd0b7cb0bc70 100644 --- a/tui/inbox.go +++ b/tui/inbox.go @@ -106,11 +106,15 @@ func NewSentInbox(emails []fetcher.Email, accounts []config.Account) *Inbox { } func NewInboxWithMailbox(emails []fetcher.Email, accounts []config.Account, mailbox MailboxKind) *Inbox { - // Build tabs: "ALL" + one per account - tabs := []AccountTab{{ID: "", Label: "ALL", Email: ""}} - for _, acc := range accounts { - label := acc.Email - tabs = append(tabs, AccountTab{ID: acc.ID, Label: label, Email: acc.Email}) + // Build tabs: empty for single account, "ALL" + accounts for multiple + var tabs []AccountTab + if len(accounts) <= 1 { + tabs = []AccountTab{{ID: "", Label: "", Email: ""}} + } else { + tabs = []AccountTab{{ID: "", Label: "ALL", Email: ""}} + for _, acc := range accounts { + tabs = append(tabs, AccountTab{ID: acc.ID, Label: acc.Email, Email: acc.Email}) + } } // Group emails by account @@ -152,7 +156,7 @@ func (m *Inbox) updateList() { if m.currentAccountID == "" { // "ALL" view - show all emails sorted by date displayEmails = m.allEmails - showAccountLabel = len(m.accounts) > 1 + showAccountLabel = !(len(m.accounts) <= 1) } else { // Specific account view displayEmails = m.emailsByAccount[m.currentAccountID] @@ -516,11 +520,15 @@ func (m *Inbox) SetEmails(emails []fetcher.Email, accounts []config.Account) { m.accounts = accounts m.allEmails = emails - // Rebuild tabs - tabs := []AccountTab{{ID: "", Label: "ALL", Email: ""}} - for _, acc := range accounts { - label := acc.Email - tabs = append(tabs, AccountTab{ID: acc.ID, Label: label, Email: acc.Email}) + // Rebuild tabs: empty for single account, "ALL" + accounts for multiple + var tabs []AccountTab + if len(accounts) <= 1 { + tabs = []AccountTab{{ID: "", Label: "", Email: ""}} + } else { + tabs = []AccountTab{{ID: "", Label: "ALL", Email: ""}} + for _, acc := range accounts { + tabs = append(tabs, AccountTab{ID: acc.ID, Label: acc.Email, Email: acc.Email}) + } } m.tabs = tabs diff --git a/tui/inbox_test.go b/tui/inbox_test.go index 9f8ce4d2c4a6a66ab1ff529192e8af4fa62a0fde..af3e31e63f7407eac5b322d10c7fed25dad5598e 100644 --- a/tui/inbox_test.go +++ b/tui/inbox_test.go @@ -124,9 +124,9 @@ func TestInboxSingleAccount(t *testing.T) { inbox := NewInbox(emails, accounts) - // Should have 2 tabs: ALL + 1 account - if len(inbox.tabs) != 2 { - t.Errorf("Expected 2 tabs, got %d", len(inbox.tabs)) + // Should have 0 tabs (visually) + if len(inbox.tabs) != 1 { + t.Errorf("Expected 1 phantom tab, got %d", len(inbox.tabs)) } }