aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Kuehler <keur@xcf.berkeley.edu>2019-10-10 15:27:07 -0700
committerBen Burwell <ben@benburwell.com>2019-10-12 20:56:39 -0400
commit8cb4a9d751d1497e1059fedb03964bc9e56e5c06 (patch)
treea0d9a94e170f3d0fc0ed949460bdbb94c65ece06
parentf1b365dfc30b7253f3baea270ebcc8d1fb754db9 (diff)
Start adding thread support
* Add threading-enabled config option * Add DirectoryThreaded and FetchDirectoryThreaded types to control path * Add generic thread type for all backends to use Signed-off-by: Kevin Kuehler <keur@xcf.berkeley.edu>
-rw-r--r--config/aerc.conf.in6
-rw-r--r--config/config.go1
-rw-r--r--lib/msgstore.go18
-rw-r--r--widgets/account.go5
-rw-r--r--worker/types/messages.go10
-rw-r--r--worker/types/thread.go6
6 files changed, 43 insertions, 3 deletions
diff --git a/config/aerc.conf.in b/config/aerc.conf.in
index ec89ff7..362dd51 100644
--- a/config/aerc.conf.in
+++ b/config/aerc.conf.in
@@ -32,6 +32,12 @@ empty-message=(no messages)
# Default: (no folders)
empty-dirlist=(no folders)
+#
+# Enable threading in the ui
+#
+# Default: false
+threading-enabled=false
+
# Enable mouse events in the ui, e.g. clicking and scrolling with the mousewheel
#
# Default: false
diff --git a/config/config.go b/config/config.go
index 133a7f4..4170b79 100644
--- a/config/config.go
+++ b/config/config.go
@@ -32,6 +32,7 @@ type UIConfig struct {
EmptyMessage string `ini:"empty-message"`
EmptyDirlist string `ini:"empty-dirlist"`
MouseEnabled bool `ini:"mouse-enabled"`
+ ThreadingEnabled bool `ini:"threading-enabled"`
NewMessageBell bool `ini:"new-message-bell"`
Spinner string `ini:"spinner"`
SpinnerDelimiter string `ini:"spinner-delimiter"`
diff --git a/lib/msgstore.go b/lib/msgstore.go
index 071a504..064ad36 100644
--- a/lib/msgstore.go
+++ b/lib/msgstore.go
@@ -21,6 +21,9 @@ type MessageStore struct {
bodyCallbacks map[uint32][]func(io.Reader)
headerCallbacks map[uint32][]func(*types.MessageInfo)
+ // If set, messages in the mailbox will be threaded
+ thread bool
+
// Search/filter results
results []uint32
resultIndex int
@@ -42,6 +45,7 @@ type MessageStore struct {
func NewMessageStore(worker *types.Worker,
dirInfo *models.DirectoryInfo,
defaultSortCriteria []*types.SortCriterion,
+ thread bool,
triggerNewEmail func(*models.MessageInfo),
triggerDirectoryChange func()) *MessageStore {
@@ -53,6 +57,8 @@ func NewMessageStore(worker *types.Worker,
bodyCallbacks: make(map[uint32][]func(io.Reader)),
headerCallbacks: make(map[uint32][]func(*types.MessageInfo)),
+ thread: thread,
+
defaultSortCriteria: defaultSortCriteria,
pendingBodies: make(map[uint32]interface{}),
@@ -157,9 +163,15 @@ func (store *MessageStore) Update(msg types.WorkerMessage) {
switch msg := msg.(type) {
case *types.DirectoryInfo:
store.DirInfo = *msg.Info
- store.worker.PostAction(&types.FetchDirectoryContents{
- SortCriteria: store.defaultSortCriteria,
- }, nil)
+ if store.thread {
+ store.worker.PostAction(&types.FetchDirectoryThreaded{
+ SortCriteria: store.defaultSortCriteria,
+ }, nil)
+ } else {
+ store.worker.PostAction(&types.FetchDirectoryContents{
+ SortCriteria: store.defaultSortCriteria,
+ }, nil)
+ }
update = true
case *types.DirectoryContents:
newMap := make(map[uint32]*models.MessageInfo)
diff --git a/widgets/account.go b/widgets/account.go
index 4e8dd17..ebc321d 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -220,6 +220,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
} else {
store = lib.NewMessageStore(acct.worker, msg.Info,
acct.getSortCriteria(),
+ acct.conf.Ui.ThreadingEnabled,
func(msg *models.MessageInfo) {
acct.conf.Triggers.ExecNewEmail(acct.acct,
acct.conf, msg)
@@ -238,6 +239,10 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
if store, ok := acct.dirlist.SelectedMsgStore(); ok {
store.Update(msg)
}
+ case *types.DirectoryThreaded:
+ if store, ok := acct.dirlist.SelectedMsgStore(); ok {
+ store.Update(msg)
+ }
case *types.FullMessage:
if store, ok := acct.dirlist.SelectedMsgStore(); ok {
store.Update(msg)
diff --git a/worker/types/messages.go b/worker/types/messages.go
index 3539139..0b9dc6e 100644
--- a/worker/types/messages.go
+++ b/worker/types/messages.go
@@ -81,6 +81,11 @@ type FetchDirectoryContents struct {
SortCriteria []*SortCriterion
}
+type FetchDirectoryThreaded struct {
+ Message
+ SortCriteria []*SortCriterion
+}
+
type SearchDirectory struct {
Message
Argv []string
@@ -152,6 +157,11 @@ type DirectoryContents struct {
Uids []uint32
}
+type DirectoryThreaded struct {
+ Message
+ Threads []*Thread
+}
+
type SearchResults struct {
Message
Uids []uint32
diff --git a/worker/types/thread.go b/worker/types/thread.go
new file mode 100644
index 0000000..265438f
--- /dev/null
+++ b/worker/types/thread.go
@@ -0,0 +1,6 @@
+package types
+
+type Thread struct {
+ Uid uint32
+ Children []*Thread
+}