aboutsummaryrefslogtreecommitdiff
path: root/worker/imap/worker.go
diff options
context:
space:
mode:
authorBen Burwell <ben@benburwell.com>2019-07-07 22:43:56 -0400
committerDrew DeVault <sir@cmpwn.com>2019-07-08 16:06:23 -0400
commitcce7cb48081ca090ac2d3a0e781dfbc25d581946 (patch)
tree0709eff3daf75ac975bc9e12f068d7951aeaefe6 /worker/imap/worker.go
parentc79577d37675c8d9ed3355c532a215377e76d3b2 (diff)
Factor UI models out of the worker message package
Before, the information needed to display different parts of the UI was tightly coupled to the specific messages being sent back and forth to the backend worker. Separating out a models package allows us to be more specific about exactly what a backend is able to and required to provide for the UI.
Diffstat (limited to 'worker/imap/worker.go')
-rw-r--r--worker/imap/worker.go29
1 files changed, 17 insertions, 12 deletions
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index 5005620..9ddaa47 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -10,6 +10,7 @@ import (
idle "github.com/emersion/go-imap-idle"
"github.com/emersion/go-imap/client"
+ "git.sr.ht/~sircmpwn/aerc/models"
"git.sr.ht/~sircmpwn/aerc/worker/types"
)
@@ -169,13 +170,15 @@ func (w *IMAPWorker) handleImapUpdate(update client.Update) {
w.selected = *status
}
w.worker.PostMessage(&types.DirectoryInfo{
- Flags: status.Flags,
- Name: status.Name,
- ReadOnly: status.ReadOnly,
-
- Exists: int(status.Messages),
- Recent: int(status.Recent),
- Unseen: int(status.Unseen),
+ Info: &models.DirectoryInfo{
+ Flags: status.Flags,
+ Name: status.Name,
+ ReadOnly: status.ReadOnly,
+
+ Exists: int(status.Messages),
+ Recent: int(status.Recent),
+ Unseen: int(status.Unseen),
+ },
}, nil)
case *client.MessageUpdate:
msg := update.Message
@@ -183,11 +186,13 @@ func (w *IMAPWorker) handleImapUpdate(update client.Update) {
msg.Uid = w.seqMap[msg.SeqNum-1]
}
w.worker.PostMessage(&types.MessageInfo{
- BodyStructure: msg.BodyStructure,
- Envelope: msg.Envelope,
- Flags: msg.Flags,
- InternalDate: msg.InternalDate,
- Uid: msg.Uid,
+ Info: &models.MessageInfo{
+ BodyStructure: msg.BodyStructure,
+ Envelope: msg.Envelope,
+ Flags: msg.Flags,
+ InternalDate: msg.InternalDate,
+ Uid: msg.Uid,
+ },
}, nil)
case *client.ExpungeUpdate:
i := update.SeqNum - 1