threading: add force-client-threads option

This patch adds a config option to force the use of client side threads.
This option will override a servers Thread capability, and only build
threads on the client. It can be enabled contextually. For example:

	[ui]
	threading-enabled = true

	[ui:folder~^Archive]
	force-client-threads = true

This config would enable threads for all views, and use client threads
for folders that start with Archive. This can be advantageous if, for
example, the folder is very large and the server has a slow response due
to building threads for the entire mailbox

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Tim Culverhouse 2022-07-05 14:48:39 -05:00 committed by Robin Jarry
parent 3a614e45fc
commit ccd042889f
5 changed files with 14 additions and 2 deletions

View file

@ -174,6 +174,11 @@ completion-popovers=true
# Default: false # Default: false
#threading-enabled=false #threading-enabled=false
# Force client-side thread building
#
# Default: false
#force-client-threads=false
[statusline] [statusline]
# Describes the format string for the statusline. # Describes the format string for the statusline.
# #

View file

@ -46,6 +46,7 @@ type UIConfig struct {
EmptyDirlist string `ini:"empty-dirlist"` EmptyDirlist string `ini:"empty-dirlist"`
MouseEnabled bool `ini:"mouse-enabled"` MouseEnabled bool `ini:"mouse-enabled"`
ThreadingEnabled bool `ini:"threading-enabled"` ThreadingEnabled bool `ini:"threading-enabled"`
ForceClientThreads bool `ini:"force-client-threads"`
FuzzyComplete bool `ini:"fuzzy-complete"` FuzzyComplete bool `ini:"fuzzy-complete"`
NewMessageBell bool `ini:"new-message-bell"` NewMessageBell bool `ini:"new-message-bell"`
Spinner string `ini:"spinner"` Spinner string `ini:"spinner"`

View file

@ -300,6 +300,12 @@ These options are configured in the *[ui]* section of aerc.conf.
Default: false Default: false
*force-client-threads*
Force threads to be built client-side. Backends that don't support threading
will always build threads client side.
Default: false
## Contextual UI Configuration ## Contextual UI Configuration

View file

@ -60,13 +60,12 @@ type MessageStore struct {
func NewMessageStore(worker *types.Worker, func NewMessageStore(worker *types.Worker,
dirInfo *models.DirectoryInfo, dirInfo *models.DirectoryInfo,
defaultSortCriteria []*types.SortCriterion, defaultSortCriteria []*types.SortCriterion,
thread bool, thread bool, clientThreads bool,
triggerNewEmail func(*models.MessageInfo), triggerNewEmail func(*models.MessageInfo),
triggerDirectoryChange func()) *MessageStore { triggerDirectoryChange func()) *MessageStore {
dirInfoUpdateDelay := 5 * time.Second dirInfoUpdateDelay := 5 * time.Second
var clientThreads bool
if !dirInfo.Caps.Thread { if !dirInfo.Caps.Thread {
clientThreads = true clientThreads = true
} }

View file

@ -295,6 +295,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
store = lib.NewMessageStore(acct.worker, msg.Info, store = lib.NewMessageStore(acct.worker, msg.Info,
acct.GetSortCriteria(), acct.GetSortCriteria(),
acct.UiConfig().ThreadingEnabled, acct.UiConfig().ThreadingEnabled,
acct.UiConfig().ForceClientThreads,
func(msg *models.MessageInfo) { func(msg *models.MessageInfo) {
acct.conf.Triggers.ExecNewEmail(acct.acct, acct.conf.Triggers.ExecNewEmail(acct.acct,
acct.conf, msg) acct.conf, msg)