Commit Graph

121 Commits

Author SHA1 Message Date
Koni Marti c5face0b6f store: reverse message list order with iterators
Reverse the order of the messages in the message list. The complexity of
reversing the order is abstracted away by the iterators. To reverse the
message list, add the following to your aerc.conf:

[ui]
reverse-msglist-order=true

Thanks to |cos| for sharing his initial implementation of reversing the
order in the message list [0].

[0]: https://git.netizen.se/aerc/commit/?h=topic/asc_sort_imap

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-10-27 22:44:39 +02:00
Tim Culverhouse bb1249164d aerc: use single event loop
Combine tcell events with WorkerMessages to better synchronize state
with IO and UI. Remove Tick loop for rendering. Use events to trigger
renders.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-10-07 10:51:53 +02:00
Tim Culverhouse 8cd4770f32 msgstore: fix data race on access to store.needsFlags
Flag fetching is debounced in the UI, creating a race condition where
fields are accessed in the AfterFunc. Protect the needsFlags field with
a mutex.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-10-02 18:58:52 +02:00
Koni Marti dc299cc8ad logging: substitute %w for %v
Subsitute the format specifier %w for %v in the logging facility. The
logging functions use a fmt.Sprintf call behind the scene which does not
recognize %w. %w should be used in fmt.Errorf when you want to wrap
errors. Hence, the log entries that use %w are improperly formatted like
this:

ERROR 2022/10/02 09:13:57.724529 worker.go:439: could not get message
info %!w(*fmt.wrapError=&{could not get structure: [snip] })
      ^

Links: https://go.dev/blog/go1.13-errors
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2022-10-02 18:56:26 +02:00
Tim Culverhouse a9af5635bc msgstore: revert 9fdc7acf5b "post messageInfo on erroneous fetch"
Commit 9fdc7acf5b ("cache: fetch flags from UI") introduced a
regression where all messages were marked as erroneous if a single one
in the fetch request had an error.

Reported-by: Jose Lombera <jose@lombera.dev>
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-09-25 11:54:26 +02:00
Tim Culverhouse 9fdc7acf5b cache: fetch flags from UI
When cached headers are fetched, an action is posted back to the Worker
to immediately fetch the flags for the message from the server (we can't
know the flags state, therefore it's not cached). When scrolling, a lag
occurs when loading cached headers because the n+1 message has to wait
for the flag request to return before the cached headers are retrieved.

Collect the message UIDs in the UI that need flags, and fetch them based
off a debounce timer in a single request. Post the action from the UI to
eliminate an (ugly) go routine in the worker.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-09-20 21:10:35 +02:00
Tim Culverhouse 01f80721e2 msgstore: post MessageInfo on erroneous fetch
When errors occur during a fetch header request, the requested headers
are deleted from pending and no information is given to the UI. Spinners
keep spinning, and ultimately as the view is refreshed, the headers are
fetched again. This can lead to infinite loops, and extremely long logs.

Update the store with a MessageInfo message when an error is received.
Have the UI display that the header couldn't be fetched in the message
list.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-09-20 00:03:36 +02:00
Tim Culverhouse cd002567e8 msgstore: do not run threadbuilder unless in threaded view
Commit 380cf13cff ("msgstore: run threadBuilder with no debounce on
DirectoryContents msg") fixed an issue related to running the
threadbuilder with a debounce. This fix causes the thread builder to run
for any DirectoryContents message, even if the view is not threaded.

Don't call runThreadBuilderNow unless in a threaded view.

Fixes: 380cf13cff ("msgstore: run threadBuilder with no debounce on DirectoryContents msg")
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-31 10:06:56 +02:00
Tim Culverhouse f530cd96f3 msgstore: enable granularity in updating of threadbuilder
Enable the msgstore to specify if an update should also update the
threadbuilder. Certain calls to msgstore.update() did not require the
threadbuilder to run, as it was either called implicitly through other
means (nextPrev during a search) OR it was not needed (IE in the case of
a DirectoryInfo message).

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-30 21:42:37 +02:00
Tim Culverhouse 380cf13cff msgstore: run threadBuilder with no debounce on DirectoryContents msg
Commit 54a0a377e0 ("threads: debounce client-side thread building")
introduced the option to debounce threadbuilding to improve performance
of client side threads. This caused a UI regression during filtering of
mailboxes:

1. The mailbox contains the full set of message UIDs
2. User filters mailbox
3. A DirectoryContents message is received from worker with the proper
   UIDs to display
4. Debounce is started (in a separate go routine)
5. The value of msgStore.Uids() is used to show pending headers, but is
   not updated until the threadbuilder runs. The full set of UIDs is
   shown briefly
6. Debounce is over, threadbuilder runs, updates msgStore.Uids(), proper
   messages show.

Run the thread builder immediately upon receipt of a DirectoryContents
message, bypassing any debounce. Performance will remain the same: the
debounce is meant to prevent multiple sequential calls to the thread
builder during scrolling. This is unlikely to occur in rapid succession
from filtering or sorting.

Fixes: https://todo.sr.ht/~rjarry/aerc/76
Fixes: 54a0a377e0 ("threads: debounce client-side thread building")
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-30 21:42:37 +02:00
Tim Culverhouse c98f704874 move: enable MoveMessages from msgstore
Enable the use of MoveMessages worker messages from the UI to the
backend. Completes implemention of MoveMessages for all supported
backends.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-22 15:46:55 +02:00
Koni Marti 588be1a284 store: improve cursor position
Improve cursor re-positioning while filtering with and without threads.
Reposition cursor in client-side threading mode with a callback that is
set during store.NextPrev(). Run callback when the threads are
constructed in order to reposition the cursor correctly. The callback is
deactivated when store.Select() is called.

Steps to reproduce two issues:

* Reproduce issue 1:

1. Activate client-side threading
2. Apply a filter, e.g. :filter -f Koni
3. Move cursor around so that a message is highlighted
4. clear filter with :clear
5. The cursor is expected to remain on the selected message but is
   actually not

* Reproduce issue 2:

1. Activate client-side threading
2. Go the end of the message list
2. Apply a filter, e.g. :filter -f Koni
5. The cursor is now at the end of the filtered results instead of at
   the beginning

This patch fixes both of those issues. Tested in regular and threaded
view according to the following check list (expected behavior in
parenthesis):

1. Apply filter from a message that remains in the filter (cursor on message,
   message selected)
2. Apply filter from a message that will not remain (cursor at the top,
   no message selected)
3. Clear filter (cursor remains on message, message selected)
4. Scroll line-by-line (threads: cursor remains on line, does not "jump"
   with message)
5. Search (cursor on first result)

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
2022-08-22 10:01:46 +02:00
Koni Marti 117f99e187 mark: (un)mark message threads
Mark or unmark the shown message threads. Threads must be available in the
message store. Use the -T option for the mark or unmark commands. Can be
used in combination with the toggle flag (-t).

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-22 09:30:37 +02:00
Koni Marti 22e6c9e4fa store: remove unneeded header callback
The message store keeps a map of callbacks for headers that are being
fetched. This is not used anywhere in the code base. Instead of a
func(*types.MessageInfo) callback use a general
func(types.WorkerMessage) in the worker.PostAction function to make it
more useful. This callback allows now to get a feedback when all headers
are fetched successfully. Note that the pending header map remains so
that the same header is not fetched multiple times.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-22 09:30:37 +02:00
Koni Marti cfc19a7ec2 store: extract marking behavior and add tests
Separate the marking functions from the message store and extract the
marking behavior into its own class with tests.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-22 09:30:37 +02:00
Tim Culverhouse 6057d156e6 delete: revert deleted messages if Delete is unsupported
Delete operations are not supported by the notmuch backend. Revert
deleted messages when the operation is not supported, and reselect the
original selection.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-05 21:57:12 +02:00
Moritz Poldrack 978d35d356 lint: homogenize operations and minor fixes (gocritic)
Apply GoDoc comment policy (comments for humans should have a space
after the //; machine-readable comments shouldn't)

Use strings.ReplaceAll instead of strings.Replace when appropriate

Remove if/else chains by replacing them with switches

Use short assignment/increment notation

Replace single case switches with if statements

Combine else and if when appropriate

Signed-off-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-04 21:58:01 +02:00
Moritz Poldrack c882cf9960 lint: removed unused code (deadcode, structcheck, unused)
Signed-off-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-04 21:58:00 +02:00
Moritz Poldrack 5ca6022d00 lint: ensure errors are at least logged (errcheck)
Signed-off-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-04 21:57:57 +02:00
Moritz Poldrack ef599aa8fc lint: simplify code (gosimple)
Replaces infinite for loops containing a select on a channel with a
single case with a range over the channel.

Removes redundant assignments to blank identifiers.

Remove unnecessary guard clause around delete().

Remove `if condition { return true } return false` with return condition

Signed-off-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-04 21:57:52 +02:00
Moritz Poldrack aaf0a0c656 lint: apply new formatting rules
Run `make fmt`.

Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-01 10:44:52 +02:00
Koni Marti 687c4777b5 store: fix nexprev when filtering
Select the first message with NextPrev when the cursor disappears after
applying a filter where the selected message is not part of. Currently,
the NextPrev would select the last message in the mailbox (like a G
jump).

To reproduce:
1) select a message
2) apply a filter where the selected message is not selected
3) move the cursor and it will jump to the last message

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-08-01 10:37:47 +02:00
Tim Culverhouse 6db766260b sort: clear sort criteria when called without arguments
Fix a regression introduced by commit c2f4404fca ("threading: enable
filtering of server-side threads"). Prior to this commit, a :sort
command (no args) would clear out the current sort criteria (or rather,
apply the value from the config). Restore this functionality.

Fixes: c2f4404fca ("threading: enable filtering of server-side threads")
Reported-by: akspecs <akspecs@gmail.com>
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-26 22:24:01 +02:00
Koni Marti 26b9c3d966 sort: show warning when sort is not supported
Use the capabilities returned by the backend to check whether sort is
implemented when the user tries to use the sort command. Print a warning
to the log when a sort request is silently dropped by the backend.

Suggested-by: |cos|
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-26 22:22:58 +02:00
Koni Marti cfbb548fb8 threads: match regular view scrolling behavior
Try to keep the position in the message list when scrolling through
threaded messages to match the scrolling behavior of the regular view.
This only needs to be implemented for the client-side threading since we
have to rebuild the threads when new messages arrive.

Reported-by: akspecs <akspecs@gmail.com>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Akspecs <akspecs@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-26 22:22:56 +02:00
Koni Marti 866867c616 threads: fix race warnings for client-side debouncing
Client-side thread debouncing happens in a different goroutine. Any
function or variable that is called or accessed by this goroutine should
be protected from a concurrent access.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-26 22:22:53 +02:00
Koni Marti 54a0a377e0 threads: debounce client-side thread building
Debounce client-side thread building in the message store. Debouncing is
useful when multiple messages are loaded, i.e. when scrolling with
PgUp/PgDown.

Without the debouncing, all client-side threads will be built everytime
the message store is updated which creates a noticable lag in the
message list ui when client-side threading is activated.

The default debouncing delay can be changed by changing
'client-threads-delay' in the UI config section.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-26 22:22:48 +02:00
Koni Marti 8f7695fde5 msgstore: implement a uid-based architecture
Change the message store architecture from an index-based to a uid-based
one. Key advantage of this design approach is that no reselect mechanism
is required anymore since it comes with the design for free.

Fixes: https://todo.sr.ht/~rjarry/aerc/43
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-26 11:34:19 +02:00
akspecs 0f86666f52 msgstore: check if message index < 0, select 0 if so
Calling :prev without this check can cause the index to go below 0 if
the current index is smaller than the value being scrolled / incremented
by. This results in the email selector wrapping around from the top to
the bottom most email in the mailbox folder due to changes in ec150f0
'store: fix Select behaviour'.

Signed-off-by: akspecs <akspecs@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-24 23:05:07 +02:00
Tim Culverhouse 4036f696ad msgstore: refactor NextPrev
Refactor NextPrev to use already existing selection methods and bounds
checking

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-24 23:05:00 +02:00
Tim Culverhouse f8e6478d46 store: fix Select behavior
Fix the behavior of the Select(index int) method to select the last
message if an index > len(list) or select from bottom of list for
negative indexes.

Thanks: akspecs <akspecs@gmail.com>
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-24 23:04:52 +02:00
Robin Jarry cd19995557 logging: use level-based logger functions
Do not pass logger objects around anymore. Shuffle some messages to make
them consistent with the new logging API. Avoid using %v when a more
specific verb exists for the argument types.

The loggers are completely disabled (i.e. Sprintf is not even called)
by default. They are only enabled when redirecting stdout to a file.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
2022-07-23 22:52:15 +02:00
Tim Culverhouse 04097e8743 msgstore: do not build threads when threaded view is off
Commit 3a614e45fc ("threading: enable toggle-threads for server-side
threads") changed the behavior of the msgstore.buildThreads variable to
reflect whether the client needs to build threads or the server will.
However, a call to runThreadbuilder was not updated with an extra
conditional. As a result, threads were built regardless of the state of
the threadedView resulting in a large performance penalty for
non-threaded views with client side threading.

Only run thread builder if threaded view is enabled.

Fixes: 3a614e45fc ("threading: enable toggle-threads for server-side threads")
Reported-by: akspecs <akspecs@gmail.com>
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Akspecs <akspecs@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-17 18:35:21 +02:00
Tim Culverhouse a953e4dbe9 threading: refactor reselect logic
This patch refactors reselection of a message during certain operations
(searching, filtering, clearing, deleting, moving, new message arrival).
The addition of server-side filtering for threaded views broke the
existing reselection logic.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 21:15:12 +02:00
Tim Culverhouse c2f4404fca threading: enable filtering of server-side threads
This patch enables the filtering of a threaded view which uses
server-built threads. Filtering is done server-side, in order to
preserve the use of server-built threads.

In adding this feature, the filtering of notmuch folders was brought up
to feature parity with the other workers. The filters function the same
(ie: they can be stacked). The notmuch filters, however, still use
notmuch syntax for the filtering.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 21:15:12 +02:00
Tim Culverhouse ccd042889f 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>
2022-07-10 21:15:12 +02:00
Tim Culverhouse 3a614e45fc threading: enable toggle-threads for server-side threads
Enable the :toggle-threads command to work for workers which have Thread
capability. The implementation of that feature has the side effect that
the threading-enabled config option now sets the default view (threaded
or not threaded) for any worker, not just IMAP or notmuch.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 21:15:12 +02:00
Tim Culverhouse a8879d79c6 msgstore: remove duplicate calls to store.update
Move and Delete commands perform a store.update() when their worker is
completed and also when the method is called. This patch removes the
call performed in the store.Move and store.Delete methods.

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-07-10 21:15:12 +02:00
Tim Culverhouse 4753cfd3e3 visual-mode: deselect messages after performing command
In order to better align to vim functionality: deselect visual mode
selections after performing a command on the selection. This patch also
introduces a new command to allow for re-selecting (remarking) the
previous selection set so that commands can be chained together. The
deselection only applies to msg commands that *do not* move the message
from the store (those types of commands already deselect):
- read/unread
- flag/unflag
- modify-labels
- copy
- pipe

Previous usage to mark several messages as read and deselect all:
Vjjj:read<Enter>:unmark -a<Enter>

New usage, similar to vim:
Vjjj:read<Enter>

To chain a command together:
Vjjj:read<Enter>:remark<Enter>{next command}<Enter>

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-06-14 22:12:42 +02:00
Tim Culverhouse 2551dd1bfa feat: add background mail polling option for all workers
Check for new mail (recent, unseen, exists counts) with an external
command, or for imap with the STATUS command, at start or on
reconnection and every X time duration

IMAP:
The selected folder is skipped, per specification. Additional config
options are included for including/excluding folders explicitly.

Maildir/Notmuch:
An external command will be run in the background to check for new mail.
An optional timeout can be used with maildir/notmuch. Default is 10s

New account options:
check-mail
check-mail-cmd (maildir/notmuch only)
check-mail-timeout (maildir/notmuch only), default 10s
check-mail-include (IMAP only)
check-mail-exclude (IMAP only)

If unset, or set less than or equal to 0, check-mail will be ignored

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-05-31 14:32:51 +02:00
Koni Marti 30d5788974 store: clean marked messages
Clean marked messages after new uids are fetched.

Commit 5c5158b3 ("store: remove callbacks on error") removed side
effects in the message store after a longer suspend period but neglected
to remove marked zombie messages.

References: https://todo.sr.ht/~rjarry/aerc/28
Co-authored-by: inwit <inwit@sindominio.net>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-05-31 14:32:45 +02:00
Koni Marti 5c5158b3c1 store: remove callbacks on error
Unmark deleted messages and remove pending headers in the callback
function when an error in the backend occurs (e.g. due to connection
issues).

The message store marks messages that should be deleted. If the delete
operation in the backend fails, messages are never unmarked and will
remain rendered as empty lines in the message list. This also affects
the move and archive commands that rely on a copy and delete operation.

A similar issue occurs with the pending headers when the operation to
fetch them fails. In this case, messages will appear as loading
indefinitely in the message list and are never re-fetched because the
corresponding pending headers from the failed operations are still
present.

Fixes: https://todo.sr.ht/~rjarry/aerc/28
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-05-06 11:02:33 +02:00
Koni Marti cb887a2d9d store: keep current message selected
Keep current message selected when clearing or changing filters and when
toggling threads.

Add -s flag to the clear command to also clear the selected message and
set cursor to the top of the message list.

Implements: https://todo.sr.ht/~rjarry/aerc/36
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-17 12:18:33 +02:00
Koni Marti f6e34e4cf1 imap: fix no-envelope-for-message error
Fix the "no envelope available for this message" error that can occur
when using the same imap mailbox in another mailclient (e.g.
through a webmail interface) at the same time.

Complements the fixes in commit 7fe7fe4 ("ui: fix panic in header
formatter") and commit 074b0a1 ("view,list: fix crash when viewing
incomplete imap messages").

The error is caused when a message attribute update is received by the
message store before the message list had a chance to fetch the proper
header first. In this case, an (incomplete) message info is stored in
the message store and the message list will never fetch the correct
header. To prevent this, add only messages to the store with a non-nil
envelope but make sure that message attribute updates are properly
merged.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-04-11 12:06:53 +02:00
Koni Marti 20218de913 store: sort messages even when a filter is applied
Sort the message list even when a filter is applied according to the
sort criteria given by the sort command.

Currently, the sort command has no effect when a filter is in use.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-25 13:07:22 +01:00
Koni Marti e50ab59284 sort: keep sort criteria applied to folder
Keep the sort criteria applied to the selected folder until the default
sort order should be restored. Call the sort command without arguments
to restore the default sort order.

The current behavior is that the default sort order is restored as soon
as the folder reloads. This happens often and then the results of the
sort command are lost. This makes the sort command not very
user-friendly. Instead, we should keep the sort criteria applied until
the user explicitly wants to restore the default sort order again.

Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-25 13:07:20 +01:00
Koni Marti 9f4da4de0c msglist: update message counter upon filter change
Update message counter in msglist when the filter is changed (either set or
cleared in the msgstore).

When we apply a filter, we change the number of uids in the message
store. This can unintentionally trigger the storeUpdate() function of
the msglist which checks the number of uids for new messages and
advances the pointer by the difference in the number of messages. This
can be avoided when we update the message counter upon changing the
filter.

Fixes: https://todo.sr.ht/~rjarry/aerc/23
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-20 10:00:50 +01:00
Koni Marti 7d2b0f579d store: fix deleting messages in filter mode
fix deleting messages when in filter mode.

Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CCIO3IVSM2JUB.3L46NM6LJZ2KB%40Archetype%3E

Reported-by: Moritz Poldrack <git@moritz.sh>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-20 10:00:23 +01:00
Koni Marti 2a19c30879 store: allow consecutive filter and search queries
Enable consecutive filter and search queries. Filter narrows down
message list consecutively and clears search results. Search applies to
the current message list.

Fixes: https://todo.sr.ht/~rjarry/aerc/24
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Inwit <inwit@sindominio.net>
Tested-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
2022-03-14 23:59:58 +01:00
Moritz Poldrack 4bc43d2741 all: fix minor issues found by staticcheck
Signed-off-by: Moritz Poldrack <git@moritz.sh>
2022-03-12 21:00:23 +01:00