diff options
author | Koni Marti <koni.marti@gmail.com> | 2022-10-20 16:43:44 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-10-27 22:44:39 +0200 |
commit | 006e10357b0e89ba3a8216ff5a6435c5d8f77187 (patch) | |
tree | 62cd69a39c68948e0e36e03a7106fc80ccc35b6e /lib/msgstore.go | |
parent | 88afe7bb4a7425fbce767a64ed454151514fa4f2 (diff) | |
download | aerc-006e10357b0e89ba3a8216ff5a6435c5d8f77187.tar.gz |
threads: reverse thread ordering
Add reverse-thread-order option to the ui config to enable reverse
display of the mesage threads. Default order is the the intial message
is on the top with all the replies being displayed below. The reverse
options will put the initial message at the bottom with the replies on
top.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/msgstore.go')
-rw-r--r-- | lib/msgstore.go | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index d6ca26e2..a22e1961 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -39,9 +39,10 @@ type MessageStore struct { sortCriteria []*types.SortCriterion - threadedView bool - buildThreads bool - builder *ThreadBuilder + threadedView bool + reverseThreadOrder bool + buildThreads bool + builder *ThreadBuilder // Map of uids we've asked the worker to fetch onUpdate func(store *MessageStore) // TODO: multiple onUpdate handlers @@ -74,7 +75,7 @@ func NewMessageStore(worker *types.Worker, dirInfo *models.DirectoryInfo, defaultSortCriteria []*types.SortCriterion, thread bool, clientThreads bool, clientThreadsDelay time.Duration, - reverseOrder bool, + reverseOrder bool, reverseThreadOrder bool, triggerNewEmail func(*models.MessageInfo), triggerDirectoryChange func(), ) *MessageStore { @@ -91,8 +92,9 @@ func NewMessageStore(worker *types.Worker, bodyCallbacks: make(map[uint32][]func(*types.FullMessage)), - threadedView: thread, - buildThreads: clientThreads, + threadedView: thread, + buildThreads: clientThreads, + reverseThreadOrder: reverseThreadOrder, filter: []string{"filter"}, sortCriteria: defaultSortCriteria, @@ -231,7 +233,7 @@ func (store *MessageStore) Update(msg types.WorkerMessage) { newMap := make(map[uint32]*models.MessageInfo) builder := NewThreadBuilder(store.iterFactory) - builder.RebuildUids(msg.Threads) + builder.RebuildUids(msg.Threads, store.reverseThreadOrder) store.uids = builder.Uids() store.threads = msg.Threads @@ -364,6 +366,14 @@ func (store *MessageStore) update(threads bool) { } } +func (store *MessageStore) SetReverseThreadOrder(reverse bool) { + store.reverseThreadOrder = reverse +} + +func (store *MessageStore) ReverseThreadOrder() bool { + return store.reverseThreadOrder +} + func (store *MessageStore) SetThreadedView(thread bool) { store.threadedView = thread if store.buildThreads { @@ -424,7 +434,7 @@ func (store *MessageStore) runThreadBuilderNow() { } } // build new threads - th := store.builder.Threads(store.uids) + th := store.builder.Threads(store.uids, store.reverseThreadOrder) // save local threads to the message store variable and // run callback if defined (callback should reposition cursor) |