all repos — emessage @ 1270fab7e89d7acac5863d061b9e4c6773222068

The EMessage email client

fixed idling
Robert Ismo me@robertismo.com
Fri, 26 Jun 2026 17:41:39 -0500
commit

1270fab7e89d7acac5863d061b9e4c6773222068

parent

1b5e93f7aec9ef8b0f1bda230181a9698e020f3e

3 files changed, 11 insertions(+), 4 deletions(-)

jump to
M app.goapp.go

@@ -46,7 +46,7 @@ Stdout()

defer app.Log("Startup finished."). Stdout() app.ctx = ctx - app.idleCtx, app.idleCancel = context.WithCancel(ctx) + app.idleCtx, app.idleCancel = context.WithCancel(app.ctx) updater := &selfupdate.Updater{ CurrentVersion: app.GetVersion(), ApiURL: "https://updater.machinetele.com/",
M email.goemail.go

@@ -29,8 +29,10 @@ if !ok {

return nil, fmt.Errorf("no active mail connection for %s", fromAddress.Value) } - if conv.ID == 0 { + if conv.Subject == "" { conv.Subject = "New via EMessage" + } + if conv.ID == 0 { if err := app.DB.Create(&conv).Error; err != nil { return nil, fmt.Errorf("failed to create conversation: %w", err) }
M mailaccount.gomailaccount.go

@@ -4,6 +4,7 @@ import (

"errors" "time" "sync" + "context" "strconv" "github.com/emersion/go-imap/v2"

@@ -426,7 +427,9 @@ for {

select { case <-app.idleCtx.Done(): app.Log("IDLE cancelled via context").Stdout() - return + app.idleCtx, app.idleCancel = context.WithCancel(app.ctx) + time.Sleep(4 * time.Second) + continue default: }

@@ -451,13 +454,15 @@ go func() {

waitChan <- idleCmd.Wait() }() + app.Log("Waiting for new messages...").Stdout().StatusLine() select { case err := <-waitChan: if err != nil { app.Log("IDLE ended with error: %v", err).Stdout() } + app.Log("IDLE stopped naturally.").Stdout() idleCmd.Close() - case <-time.After(1 * time.Minute): + case <-time.After(15 * time.Second): app.Log("IDLE timeout – restarting").Stdout() idleCmd.Close() case <-app.idleCtx.Done():