aboutsummaryrefslogtreecommitdiffstats
path: root/lib/msgstore.go
Commit message (Collapse)AuthorAgeFilesLines
* store: keep current message selectedKoni Marti2022-04-171-1/+22
| | | | | | | | | | | | 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>
* imap: fix no-envelope-for-message errorKoni Marti2022-04-111-1/+3
| | | | | | | | | | | | | | | | | | | | | 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>
* store: sort messages even when a filter is appliedKoni Marti2022-03-251-0/+1
| | | | | | | | | | 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>
* sort: keep sort criteria applied to folderKoni Marti2022-03-251-3/+4
| | | | | | | | | | | | | | | 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>
* msglist: update message counter upon filter changeKoni Marti2022-03-201-0/+11
| | | | | | | | | | | | | | | | 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>
* store: fix deleting messages in filter modeKoni Marti2022-03-201-0/+8
| | | | | | | | | | | 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>
* store: allow consecutive filter and search queriesKoni Marti2022-03-141-7/+21
| | | | | | | | | | | | 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>
* all: fix minor issues found by staticcheckMoritz Poldrack2022-03-121-1/+1
| | | | Signed-off-by: Moritz Poldrack <git@moritz.sh>
* threading: honor user-defined sort criteriaKoni Marti2022-03-091-36/+12
| | | | | | | | | | | | | | | Apply the user-defined sort criteria to the message with the highest uid in a threaded discussion. Restore the default sort order when leaving threading mode. Commit 7811620eb809 ("threading: implement on-the-fly message threading") introduced message threading with the threaded messages being only sorted by their message uids irrespective of the defined sorting criteria. It did not restore the default sort order either. Reported-by: Sebastien Binet <s@sbinet.org> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* threading: implement on-the-fly message threadingKoni Marti2022-02-241-1/+78
| | | | | | | | | | | | | | | | | | | | implement message threading on the message store level using the jwz algorithm. Build threads on-the-fly when new message headers arrive. Use the references header to create the threads and the in-reply-to header as a fall-back option in case no references header is present. Does not run when the worker provides its own threading (e.g. imap server threads). Include only those message headers that have been fetched and are stored in the message store. References: https://www.jwz.org/doc/threading.html Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net> Tested-by: akspecs <akspecs@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgstore: fetch missing headers in visual modeKoni Marti2022-01-221-0/+7
| | | | | | | | | | | fetches missing headers when in visual selection mode. This prevents large archive operations from panicking due to a nil pointer dereference. The archive command will return an error to the ui when a nil message is encountered to signal that the message store is not ready yet. Signed-off-by: Koni Marti <koni.marti@gmail.com>
* messages: allow displaying email threadsy0ast2021-11-131-5/+50
| | | | | | | | | | | | | Display threads in the message list. For now, only supported by the notmuch backend and on IMAP when the server supports the THREAD extension. Setting threading-enable=true is global and will cause the message list to be empty with maildir:// accounts. Co-authored-by: Kevin Kuehler <keur@xcf.berkeley.edu> Co-authored-by: Reto Brunner <reto@labrat.space> Signed-off-by: Robin Jarry <robin@jarry.cc>
* go.mod: change base git urlRobin Jarry2021-11-051-3/+3
| | | | | | | I'm not sure what are the implications but it seems required. Link: https://github.com/golang/go/issues/20883 Signed-off-by: Robin Jarry <robin@jarry.cc>
* Fix linter warningsReto Brunner2021-02-261-1/+1
| | | | | | * Remove redundant return (code was never reached) * Remove redundant type information * Rename unused function parameters to "_"
* run go fmtReto Brunner2020-07-171-2/+2
|
* Remove deleted messages from search/filter resultsAndrew Jeffery2020-07-101-0/+9
| | | | | This ensures that when moving/deleting messages with a filter active the view gets updated properly.
* Add additional flagging functionalityARaspiK2020-07-081-4/+5
| | | | | | | | | | | | | | More mail flags can now be set, unset, and toggled, not just the read/seen flag. This functionality is implemented with a new `:flag` and `:unflag` command, which are extensions to the matching `:read` and `:unread` commands, adding support for different flags. In fact, the `read`/`unread` commands are now recognized aliases to `flag`/`unflag`. The new commands are also well documented in aerc(1). The change mostly extends the previous read/unread setting functionality by adding a selection for the flag to change.
* Set AnsweredFlag on successful replySrivathsan Murali2020-05-251-0/+9
|
* FetchBodyPart doesn't need the parent body structureReto Brunner2020-05-171-2/+1
|
* imap: Remove FetchMessageBodyPart.{Encoding,Charset}Reto Brunner2020-05-161-13/+2
| | | | Fixes https://todo.sr.ht/~sircmpwn/aerc2/352 exactly as suggested by emersion.
* store.FetchFull: Change callback type to expose entire messageBen Fiedler2020-05-011-5/+5
| | | | | This is a prerequisite for allowing the FetchFull message to return both the message content and the message headers.
* remove the dirInfoUpdateRequest functionalityReto Brunner2020-02-291-15/+0
| | | | | The notmuch worker followed suit in handling the dirInfo submission manually. That removes the last user so we might as well remove the functionality.
* Don't show empty message while sortingJeffas2020-02-281-4/+8
| | | | | | This changes the ui to show the spinner while we are sorting. It only shows one line of the spinner since there are an unknown number of messages at this time.
* lib/msgstore: debounce directoryUpdateRequestsReto Brunner2020-02-251-3/+17
| | | | | | | | Apparently sending an event for every incoming messageInfo slows down the application significantly. Therefore this slows down the emmision rate, on the cost of being out of date in some cases.
* Revert "Only fetch the directory contents when we are switching directories"Reto Brunner2020-02-191-0/+8
| | | | | | | This reverts commit bd4df530095ee343778a59120a9e641c01010b0f. I did not properly untangle the opening / dirlist update of each other. This interferes with the imap worker, hence the revert
* Request DirInfo whenever the unread count may have changedReto Brunner2020-02-161-0/+9
| | | | | | | Actions such as read / unread or the addition of new messages do change the read/unread/recent count. Hence we request an update from the workers. Workers going over the network should probably cache the information and invalidate it only if necessary
* Only fetch the directory contents when we are switching directoriesReto Brunner2020-02-161-8/+0
| | | | | | Previously, sending a DirectoryInfo assumed that a directory change happened. However we don't want that if we only want to update the unread message count.
* FetchBodyParts: decode source in the workersReto Brunner2020-01-051-3/+14
| | | | | | | Previously the workers returned a mixture of decoded / encoded parts. This lead to a whole bunch of issues. This commit changes the msgviewer and the commands to assume parts to already be decoded
* Add labels to index format (%g)Reto Brunner2019-12-271-0/+1
| | | | Exposes the notmuch tags accordingly, stubs it for the maildir worker.
* msgstore: add marking functionalityReto Brunner2019-12-211-4/+127
|
* Break early when delete happens in outdated stateKiril Vladimiroff2019-12-121-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | A panic could happen when multiple delete messages are sent one after another without waiting until there are no messages left to be deleted: panic: runtime error: makeslice: len out of range goroutine 1 [running]: git.sr.ht/~sircmpwn/aerc/lib.(*MessageStore).Update(0xc000592e00, 0xa8fe60, 0xc0003340f0) /go/src/git.sr.ht/~sircmpwn/aerc/lib/msgstore.go:222 +0x5b8 git.sr.ht/~sircmpwn/aerc/widgets.(*AccountView).onMessage(0xc0000a0460, 0xa8fe60, 0xc0003340f0) /go/src/git.sr.ht/~sircmpwn/aerc/widgets/account.go:251 +0x307 git.sr.ht/~sircmpwn/aerc/widgets.(*AccountView).Tick(0xc0000a0460, 0xc0001496b0) /go/src/git.sr.ht/~sircmpwn/aerc/widgets/account.go:90 +0xa1 git.sr.ht/~sircmpwn/aerc/widgets.(*Aerc).Tick(0xc0000a9f40, 0xc000020501) /go/src/git.sr.ht/~sircmpwn/aerc/widgets/aerc.go:123 +0x91 main.main() /go/src/git.sr.ht/~sircmpwn/aerc/aerc.go:182 +0x5bf The make that blows up is: uids := make([]uint32, len(store.uids)-len(msg.Uids)) This change simply checks whether the make is going to be valid before starting to work on the actual delete. If there are more messages queued to be deleted than what's left in the store, then we're obviously in an inconsistent state, ask for an update and break.
* Initialize an empty message map in the message store on initializationRafael Castillo2019-12-071-2/+3
| | | | | This addresses occasional crashes when a `MessageInfo` event reached the message store before `DirectoryContents`, particularly on slower (imap) accounts.
* lib/msgstore: fix invalid callback invocationReto Brunner2019-10-141-1/+1
| | | | | creating a directory must not invoke the callback, as this is meant for the completion of the move
* Revert "Show spinner when fetching contents"Drew DeVault2019-10-091-6/+3
| | | | This reverts commit 1339faf7881f33762c6e0a4915404e362fc51de1.
* Preserve sorting order in search resultsJeffas2019-10-091-0/+2
| | | | | This ensures that the search results follow the order of the current sort so that cycling throught the results proceeds in displayed order.
* Show spinner when fetching contentsJeffas2019-10-091-3/+6
| | | | | The spinner should be shown when fetching the contents as we don't know at that point whether there are some messages or not.
* Add sorting functionalityJeffas2019-09-201-1/+16
| | | | | | | | There is a command and config option. The criteria are a list of the sort criterion and each can be individually reversed. This only includes support for sorting in the maildir backend currently. The other backends are not supported in this patch.
* Revert "Fix out-of-order messages by sorting as we display"Drew DeVault2019-09-181-1/+1
| | | | This reverts commit ac99d9ed62644cf0259bdd79481b28c3fbcef650.
* Add modify-labels commandReto Brunner2019-09-121-0/+9
| | | | | This adds the event type as well as the command implementation, but no backend supports it yet.
* Add display of unread messages in dirlistJeffas2019-09-111-0/+8
| | | | | | | Add an onUpdateDirs handler. This is used to invalidate the dirlist and redraw with the correct number of recent/unread/total messages is shown. A config option and formatting options are provided.
* widgets: remove redundant key check, delete is no-op if key is emptyWagner Riffel2019-09-041-6/+2
| | | | Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
* extract search criteria parsing into the backendsReto Brunner2019-08-291-4/+2
|
* Fix out-of-order messages by sorting as we displayStephen Brennan2019-08-291-1/+1
| | | | | | | | | | Sometimes I observe out-of-order messages when using a maildir inbox. It appears that the UIDs for these messages are returned out of order by the MessageStore. In order for a maildir MessageStore to return messages in most recently received order, it must have already opened all messages and parsed the date to use as a sort key. Rather than implement that, simply sort messages by time as we display. This fix shows my emails in order.
* Implement next-folder using NextPrev with amountJelle Besseling2019-08-071-3/+3
| | | | | | This fixes ~sircmpwn/aerc2#182 https://todo.sr.ht/~sircmpwn/aerc2/182
* Ring bell when new messages arrive0.2.0Ben Burwell2019-07-291-3/+12
| | | | | | | | Add a "new-message-bell" option to the UI section of aerc.conf. A new hook into the message store allows the msglist widget to detect new messages being added to the displayed list. When new messages are delivered, and the new-message-bell option is enabled (as it is by default), the terminal will beep.
* lib/msgstore: Fix Select, Next, Prev with filterKevin Kuehler2019-07-291-8/+10
| | | | | | | | When filter is active we want to use store.results instead of store.uids, since we are dealing with a subset of the uids. Otherwise any methods involving len will have undefined behavior. Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
* Add new-email triggerJeffas2019-07-261-1/+18
| | | | | | | | | | | | | | | | | This patch sets up the trigger config section of aerc.conf. Each trigger has its own function which is called from the place where it is triggered. Currently only the new-email trigger is implemented. The triggers make use of format strings. For instance, in the new-email trigger this allows the user to select the trigger command and also the information extracted from the command and placed into their command. To actually execute the trigger commands the keypresses are simulated. Further triggers can be implemented in the future. Formatting of the command is moved to a new package.
* Make :next-result :prev-result relative to cursorKevin Kuehler2019-07-251-0/+9
| | | | Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
* Implement :filter, :clearKevin Kuehler2019-07-191-14/+33
| | | | Signed-off-by: Kevin Kuehler <keur@ocf.berkeley.edu>
* #190 Handle gmail duplicate folderDaniel Bridges2019-07-111-0/+2
|