Detailed changes
@@ -64,6 +64,7 @@ func LoadConfig() (*Config, error) {
}
return &config, nil
}
+
// IMAPServer returns the IMAP server address based on the service provider.
// This is used to connect to the email provider's IMAP server.
// It returns an empty string if the service provider is not supported.
@@ -77,4 +78,4 @@ func (c *Config) IMAPServer() string {
default:
return ""
}
-}
+}
@@ -266,27 +266,27 @@ func moveEmail(cfg *config.Config, uid uint32, destMailbox string) error {
}
func DeleteEmail(cfg *config.Config, uid uint32) error {
- c, err := connect(cfg)
- if err != nil {
- return err
- }
- defer c.Logout()
+ c, err := connect(cfg)
+ if err != nil {
+ return err
+ }
+ defer c.Logout()
- if _, err := c.Select("INBOX", false); err != nil {
- return err
- }
+ if _, err := c.Select("INBOX", false); err != nil {
+ return err
+ }
- seqSet := new(imap.SeqSet)
- seqSet.AddNum(uid)
+ seqSet := new(imap.SeqSet)
+ seqSet.AddNum(uid)
- item := imap.FormatFlagsOp(imap.AddFlags, true)
- flags := []interface{}{imap.DeletedFlag}
+ item := imap.FormatFlagsOp(imap.AddFlags, true)
+ flags := []interface{}{imap.DeletedFlag}
- if err := c.UidStore(seqSet, item, flags, nil); err != nil {
- return err
- }
+ if err := c.UidStore(seqSet, item, flags, nil); err != nil {
+ return err
+ }
- return c.Expunge(nil)
+ return c.Expunge(nil)
}
func ArchiveEmail(cfg *config.Config, uid uint32) error {
@@ -298,4 +298,4 @@ func ArchiveEmail(cfg *config.Config, uid uint32) error {
archiveMailbox = "Archive"
}
return moveEmail(cfg, uid, archiveMailbox)
-}
+}
@@ -360,4 +360,4 @@ func main() {
fmt.Printf("Alas, there's been an error: %v", err)
os.Exit(1)
}
-}
+}
@@ -163,4 +163,4 @@ func SendEmail(cfg *config.Config, to []string, subject, plainBody, htmlBody str
addr := fmt.Sprintf("%s:%d", smtpServer, smtpPort)
return smtp.SendMail(addr, auth, cfg.Email, to, msg.Bytes())
-}
+}
@@ -87,4 +87,4 @@ func (m Choice) View() string {
b.WriteString(helpStyle.Render("Use ↑/↓ to navigate, enter to select, and ctrl+c to quit."))
return docStyle.Render(b.String())
-}
+}
@@ -220,4 +220,4 @@ func (m *Composer) View() string {
}
return composerView.String()
-}
+}
@@ -86,4 +86,4 @@ func TestComposerUpdate(t *testing.T) {
t.Errorf("Mismatched SendEmailMsg.\nGot: %+v\nWant: %+v", sendMsg, expectedMsg)
}
})
-}
+}
@@ -142,4 +142,4 @@ func (m *EmailView) View() string {
}
return fmt.Sprintf("%s\n%s\n%s\n%s", styledHeader, m.viewport.View(), attachmentView, help)
-}
+}
@@ -122,4 +122,4 @@ func (m *FilePicker) View() string {
b.WriteString("\n" + helpStyle.Render("↑/↓: navigate • enter: select • backspace: up • esc: cancel"))
return docStyle.Render(b.String())
-}
+}
@@ -28,8 +28,8 @@ func (i item) FilterValue() string { return i.title + " " + i.desc }
type itemDelegate struct{}
-func (d itemDelegate) Height() int { return 1 }
-func (d itemDelegate) Spacing() int { return 0 }
+func (d itemDelegate) Height() int { return 1 }
+func (d itemDelegate) Spacing() int { return 0 }
func (d itemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd { return nil }
func (d itemDelegate) Render(w io.Writer, m list.Model, index int, listItem list.Item) {
i, ok := listItem.(item)
@@ -169,4 +169,4 @@ func (m *Inbox) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (m *Inbox) View() string {
return "\n" + m.list.View()
-}
+}
@@ -121,4 +121,4 @@ func (m *Login) View() string {
m.inputs[3].View(),
helpStyle.Render("\nenter: save • tab: next field • esc: back to menu"),
)
-}
+}
@@ -109,4 +109,4 @@ type DiscardDraftMsg struct {
}
// RestoreDraftMsg signals that the cached draft should be restored.
-type RestoreDraftMsg struct{}
+type RestoreDraftMsg struct{}
@@ -10,13 +10,13 @@ import (
var (
DialogBoxStyle = lipgloss.NewStyle().
- Border(lipgloss.RoundedBorder()).
- BorderForeground(lipgloss.Color("#874BFD")).
- Padding(1, 0).
- BorderTop(true).
- BorderLeft(true).
- BorderRight(true).
- BorderBottom(true)
+ Border(lipgloss.RoundedBorder()).
+ BorderForeground(lipgloss.Color("#874BFD")).
+ Padding(1, 0).
+ BorderTop(true).
+ BorderLeft(true).
+ BorderRight(true).
+ BorderBottom(true)
HelpStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("240"))
SuccessStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("42")).Bold(true)
@@ -27,15 +27,15 @@ var DocStyle = lipgloss.NewStyle().Margin(1, 2)
// A simple model for showing a status message
type Status struct {
- spinner spinner.Model
- message string
+ spinner spinner.Model
+ message string
}
func NewStatus(msg string) Status {
- s := spinner.New()
- s.Spinner = spinner.Dot
- s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
- return Status{spinner: s, message: msg}
+ s := spinner.New()
+ s.Spinner = spinner.Dot
+ s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205"))
+ return Status{spinner: s, message: msg}
}
func (m Status) Init() tea.Cmd { return m.spinner.Tick }
@@ -48,4 +48,4 @@ func (m Status) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (m Status) View() string {
return fmt.Sprintf("\n\n %s %s\n\n", m.spinner.View(), m.message)
-}
+}
@@ -105,4 +105,4 @@ func ProcessBody(rawBody string) (string, error) {
text = re.ReplaceAllString(text, "\n\n")
return text, nil
-}
+}