aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Kuehler <keur@xcf.berkeley.edu>2019-10-28 12:07:07 -0700
committerBen Burwell <ben@benburwell.com>2019-10-29 11:07:55 -0400
commit8bc3ccb9017b04aafccafa294f219ced5b41a372 (patch)
tree73abb7b026bf955582ca3e9c8f84c8b3c858258b
parent37f33ad65bfbfa69e620fcb0fdcff6393a251ac7 (diff)
Add manual threading to the pipeline
Signed-off-by: Kevin Kuehler <keur@xcf.berkeley.edu>
-rw-r--r--lib/msgstore.go13
-rw-r--r--widgets/account.go4
-rw-r--r--worker/imap/open.go17
-rw-r--r--worker/imap/worker.go2
-rw-r--r--worker/types/messages.go9
5 files changed, 43 insertions, 2 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go
index ccde2c2..bc55255 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -171,6 +171,15 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
case *types.DirectoryInfo:
store.DirInfo = *msg.Info
if store.thread {
+ store.worker.PostAction(&types.FetchNativeThreadSupport{}, nil)
+ } else {
+ store.worker.PostAction(&types.FetchDirectoryContents{
+ SortCriteria: store.defaultSortCriteria,
+ }, nil)
+ }
+ update = true
+ case *types.NativeThreadSupport:
+ if msg.HasSupport {
store.worker.PostAction(&types.FetchDirectoryThreaded{
SortCriteria: store.defaultSortCriteria,
}, nil)
@@ -178,8 +187,8 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
store.worker.PostAction(&types.FetchDirectoryContents{
SortCriteria: store.defaultSortCriteria,
}, nil)
+ update = true
}
- update = true
case *types.DirectoryThreaded:
var (
uids []uint32
@@ -190,7 +199,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
msg.ThreadRoot.Traverse(false, func(t *types.Thread) bool {
uid := t.Uid
uids = append([]uint32{uid}, uids...)
- flattened = append([]*types.Thread{t}, flattened...)
+ flattened = append(flattened, t)
if msg, ok := store.Messages[uid]; ok {
newMap[uid] = msg
} else {
diff --git a/widgets/account.go b/widgets/account.go
index ebc321d..d3f94cc 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -239,6 +239,10 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
if store, ok := acct.dirlist.SelectedMsgStore(); ok {
store.Update(msg)
}
+ case *types.NativeThreadSupport:
+ if store, ok := acct.dirlist.SelectedMsgStore(); ok {
+ store.Update(msg)
+ }
case *types.DirectoryThreaded:
if store, ok := acct.dirlist.SelectedMsgStore(); ok {
store.Update(msg)
diff --git a/worker/imap/open.go b/worker/imap/open.go
index 1152887..c7a479a 100644
--- a/worker/imap/open.go
+++ b/worker/imap/open.go
@@ -50,6 +50,23 @@ func (imapw *IMAPWorker) handleFetchDirectoryContents(
}
}
+func (imapw *IMAPWorker) handleNativeThreadSupport(
+ msg *types.FetchNativeThreadSupport) {
+ hasSupport, err := imapw.client.tc.SupportThread()
+ if err != nil {
+ imapw.worker.PostMessage(&types.Error{
+ Message: types.RespondTo(msg),
+ Error: err,
+ }, nil)
+ } else {
+ imapw.worker.PostMessage(&types.NativeThreadSupport{
+ Message: types.RespondTo(msg),
+ HasSupport: hasSupport,
+ }, nil)
+ imapw.worker.PostMessage(&types.Done{types.RespondTo(msg)}, nil)
+ }
+}
+
func (imapw *IMAPWorker) handleDirectoryThreaded(
msg *types.FetchDirectoryThreaded) {
imapw.worker.Logger.Printf("Fetching threaded UID list")
diff --git a/worker/imap/worker.go b/worker/imap/worker.go
index 1ba3774..ed1ad9e 100644
--- a/worker/imap/worker.go
+++ b/worker/imap/worker.go
@@ -165,6 +165,8 @@ func (w *IMAPWorker) handleMessage(msg types.WorkerMessage) error {
w.handleFetchDirectoryContents(msg)
case *types.FetchDirectoryThreaded:
w.handleDirectoryThreaded(msg)
+ case *types.FetchNativeThreadSupport:
+ w.handleNativeThreadSupport(msg)
case *types.CreateDirectory:
w.handleCreateDirectory(msg)
case *types.FetchMessageHeaders:
diff --git a/worker/types/messages.go b/worker/types/messages.go
index d5f2484..2cde38f 100644
--- a/worker/types/messages.go
+++ b/worker/types/messages.go
@@ -81,6 +81,10 @@ type FetchDirectoryContents struct {
SortCriteria []*SortCriterion
}
+type FetchNativeThreadSupport struct {
+ Message
+}
+
type FetchDirectoryThreaded struct {
Message
SortCriteria []*SortCriterion
@@ -157,6 +161,11 @@ type DirectoryContents struct {
Uids []uint32
}
+type NativeThreadSupport struct {
+ Message
+ HasSupport bool
+}
+
type DirectoryThreaded struct {
Message
ThreadRoot *Thread