fix: draft saving race condition (#352)

Marwan051 created

fix: resolve race condition in draft saving and ran make lint

Change summary

main.go             | 10 +++++-----
tui/mailing_list.go |  8 ++++----
view/html.go        |  1 -
3 files changed, 9 insertions(+), 10 deletions(-)

Detailed changes

main.go 🔗

@@ -150,11 +150,11 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 		// Save draft to disk
 		if msg.ComposerState != nil {
 			draft := msg.ComposerState.ToDraft()
-			go func() {
-				if err := config.SaveDraft(draft); err != nil {
-					log.Printf("Error saving draft: %v", err)
-				}
-			}()
+
+			if err := config.SaveDraft(draft); err != nil {
+				log.Printf("Error saving draft: %v", err)
+			}
+
 		}
 		m.current = tui.NewChoice()
 		m.current, _ = m.current.Update(tea.WindowSizeMsg{Width: m.width, Height: m.height})

tui/mailing_list.go 🔗

@@ -29,10 +29,10 @@ func NewMailingListEditor() *MailingListEditor {
 	addr.Placeholder = "e.g., alice@example.com, bob@example.com"
 
 	return &MailingListEditor{
-		nameInput:  name,
-		addrInput:  addr,
-		focus:      0,
-		editIndex:  -1,
+		nameInput: name,
+		addrInput: addr,
+		focus:     0,
+		editIndex: -1,
 	}
 }
 

view/html.go 🔗

@@ -56,7 +56,6 @@ func getTerminalCellSize() int {
 	return defaultCellHeight
 }
 
-
 // hyperlinkSupported checks if the terminal supports OSC 8 hyperlinks.
 func hyperlinkSupported() bool {
 	term := strings.ToLower(os.Getenv("TERM"))