aboutsummaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* accounts: allow fnmatch-style wildcards in aliasesJason Cox2023-10-221-2/+5
| | | | | | | | | | | | | | | | | Wildcard aliases make it possible to always reply from the same address to which a message was addressed, which is useful for catch-all email domains. Support fnmatch-style wildcards in only the address portion of an alias. When replying to a message that matches a wildcard alias, substitute the matching email address for the wildcard address, but keep the name specified with the wildcard address. For example, when the alias "Someone Awesome" <*@someone.com> is present, the reply to an email addressed to "Someone" <hi@someone.com> would be from "Someone Awesome" <hi@someone.com>. Signed-off-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Robin Jarry <robin@jarry.cc>
* sort: new `flagged` sorting criteriaVitaly Ovchinnikov2023-10-131-0/+2
| | | | | | | | | Add new `flagged` criteria to `:sort` command (and apparently to the `sort` config option). Good for moving important stuff up. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Reviewed-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* ui: export global functionsRobin Jarry2023-10-112-47/+28
| | | | | | | | | | | | | There is no need for an UI object. The Aerc.ui field is unused. And there is a single instance of it anyway. Move the object's public fields as global variables and change methods to public functions. This makes the code cleaner and removes boilerplate. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* commands: add :toggle-thread-context commandTim Culverhouse2023-09-271-0/+8
| | | | | | | | | Add a command to toggle the display of an thread-context. Update CHANGELOG. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* ui: enable showing of thread-contextTim Culverhouse2023-09-272-2/+12
| | | | | | | | | | | | | | | Add a UI config value to enable showing of "thread-context", similar to `notmuch show --entire-thread=true`. Add an associated style called "msglist_thread_context" which can be used to style such messages. Currently this feature is only supported by notmuch. It would be possible for maildir to implement as well, IMAP with gmail custom extensions, and JMAP. This patch merely implements the notmuch version and puts the groundwork in for handling these sorts of displays. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* xdg: fix unit tests on macosRobin Jarry2023-09-191-0/+4
| | | | | | | | | | | | | | | | | When any XDG_*_HOME or XDG_RUNTIME_DIR variables are set, this causes test failures. FAIL: TestConfigPath//home/user/Library/Preferences/aerc/accounts.conf (0.00s) xdg_test.go:86: got "/Users/vitaly/.config/aerc/accounts.conf" expected "/home/user/Library/Preferences/aerc/accounts.conf" Avoid leaking the local user's environment in the unit tests. Always override the XDG_* variables. Fixes: fff16640ad7c ("xdg: add functions to deal with user home paths") Reported-by: Vitaly Ovchinnikov <v@postbox.nz> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Vitaly Ovchinnikov <v@postbox.nz>
* config: make all message list symbols/icons configurableowl2023-09-191-6/+6
| | | | | | | | | | This patch removes the hard coded letters (which don't make sense in all languages), and replaces them with configurable icons, like the existing `icon-attachment` and other icons. Signed-off-by: owl <owl@u8.is> Acked-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Bence Ferdinandy <bence@ferdinandy.com>
* hyperlinks: better parsing of emails without mailto prefixesVitaly Ovchinnikov2023-09-192-1/+36
| | | | | | | | | | | Add some new tests from the emails I have and make them work by adjusting the code that looks for hyperlinks. The idea is to treat "inline" emails (those without mailto:) a little bit different and stop a little earlier while looking for their ends. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Acked-by: Robin Jarry <robin@jarry.cc>
* msgstore: ensure selection when calling sortTim Culverhouse2023-08-311-0/+5
| | | | | | | | | | | | | | | When using notmuch and changing labels, there is no reselection logic as there is when using a :mv command for other backends. This results in any label change that removes the message from the current query in having no selection. Add some simple reselection logic in the Sort callback so any call to Sort (which will refresh the message list) ensures the previously selected message is still selected, and if it isn't in the store anymore we select the same index of message as was previously selected. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Inwit <inwit@sindominio.net> Acked-by: Robin Jarry <robin@jarry.cc>
* notmuch: add notmuch bindingsTim Culverhouse2023-08-3010-0/+1074
| | | | | | | | | aerc is using an unmaintained fork of a not-well-functioning notmuch binding library. Add custom bindings directly into the aerc repo to make them more maintainable and more customizable to our needs. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* xdg: get rid of deprecated dependenciesRobin Jarry2023-08-275-28/+17
| | | | | | | | | | | github.com/mitchellh/go-homedir has not received any update since 2019. The last release of github.com/kyoh86/xdg was in 2020 and it has been marked as deprecated by its author. Replace these with internal functions. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
* xdg: add functions to deal with user home pathsRobin Jarry2023-08-274-0/+403
| | | | | | | | | | | | | These are intended to replace the following deprecated libraries: github.com/kyoh86/xdg github.com/mitchellh/go-homedir The feature set should be roughly equivalent with some tweaks to make our life easier in aerc. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
* attach: add an option to pipe the attachments inVitaly Ovchinnikov2023-08-051-18/+22
| | | | | | | | | | | | | | | Add the -r option to :attach so that the attachments can be piped in from a command. Example: :attach -r image.jpg read-jpeg-from-clipboard.sh It takes two parameters: the attachment name (to be used in the email and to get the MIME type from) and the command to execute and read the output. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Acked-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com>
* hooks: add account and folder to mail-received envRobin Jarry2023-08-041-0/+4
| | | | | | | | Add AERC_ACCOUNT and AERC_FOLDER to the environment of the mail-received hook command. Signed-off-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Tristan Partin <tristan@partin.io>
* msglist: fetch headers even when not focusedRobin Jarry2023-08-041-7/+28
| | | | | | | | | | | | | | Do not rely on MessageList.Draw only to fetch missing headers. In Draw, report the current scroll offset and length to the message store and use them to determine if a new message UID should be candidate for fetching headers. This allows the mail-received hook to work even when the message list is not focused. Fixes: https://todo.sr.ht/~rjarry/aerc/147 Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Tristan Partin <tristan@partin.io>
* watchers: move filesystem monitoring stuff in libRobin Jarry2023-08-043-0/+200
| | | | | | | No functional change. This will allow reuse in other parts of aerc. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com>
* templates: attach directly from templatesKoni Marti2023-08-032-0/+28
| | | | | | | | | | | | | | | | | | Attach a file from templates. Add a split template function. {{- .Attach "LICENSE" -}} or {{range (exec "find ./doc -type f -name *.scd" "" | split "\n") -}} {{with . }} {{- $.Attach . -}} {{- end}} {{- end}} Fixes: https://todo.sr.ht/~rjarry/aerc/109 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* mouse: fix offset in tab title clickable areaBence Ferdinandy2023-08-031-10/+18
| | | | | | | | | | | | | | | | Since templates have been introduced into the tab titles the clickable area has been offset from the actual title. This is because the clickable areas are calculated based on the tab names, which can now be different from the acually shown titles. Extract the logic of getting the display name of a tab from TabStrip and add as method of Tab. Also extract the magic constant 32. Use the method and const in both clicked and Draw. Switch from using len() to runewidth, when calculating the length of the display name. Fixes: https://todo.sr.ht/~rjarry/aerc/162 Signed-off-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc> Reviewed-by: Koni Marti <koni.marti@gmail.com>
* wizard: display warning when focus is lostKoni Marti2023-08-031-0/+6
| | | | | | | | | | | | | | | Display the warning that the password is stored in plaintext after the focus of the password input field is lost. The current behavior of showing the warning after the first character is entered is ackward and confusing. It also eliminates the need to debounce the warning when a password is pasted. Reported-by: Brad <super1337@posteo.net> Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* textinput: fix deleteWord with an only whitespaceOskar Sharipov2023-07-282-1/+73
| | | | | | | | | | | Fix a panic in the textinput.deleteWord when text is a whitespace symbol. Add tests for textinput. Fixes: https://todo.sr.ht/~rjarry/aerc/183 Signed-off-by: Oskar Sharipov <oskargit@riseup.net> Acked-by: Robin Jarry <robin@jarry.cc>
* templates: add ThreadCount and ThreadFoldedKoni Marti2023-07-161-8/+26
| | | | | | | | | | | | | | Add the number of threads and a flag to indicated folded threads to the template data. Use {{.ThreadCount}} and {{.ThreadFolded}} in template expression for the message list. column-subject = {{.ThreadPrefix}}{{if .ThreadFolded}}[{{.ThreadCount}}] {{end}}{{.Subject}} Update default configuration accordingly. Signed-off-by: Koni Marti <koni.marti@gmail.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* store: implement thread foldingKoni Marti2023-07-162-1/+39
| | | | | | | | Implement thread folding on the message store level. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* threadbuilder: store uid/thread associationKoni Marti2023-07-162-35/+39
| | | | | | | | | | | | | | Store the association between uids and threads in a map instead of just having the threads in a slice. This simplifies the lookup of a thread when we have an uid and we can avoid computationally expensive tree walks. The threadbuilder will rebuild the uids from the given thread structure. Hence there is no need now to keep a threads slice around. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc> Tested-by: inwit <inwit@sindominio.net>
* lib: invert logic of mimeDB lookupMoritz Poldrack2023-07-061-4/+2
| | | | | | | This just looked weird. Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
* templates: process reversed names betterVitaly Ovchinnikov2023-06-292-3/+135
| | | | | | | | | | | | | | | | | | | Change the behavior of `names`, `firstnames` and `initials` functions in templates so they better process names formatted like this: "Last Name, First Name" Basically, if the name contains one (and only one) comma, its parts are flipped so the first name always goes first. This helps to do "Hello Name" in templates regardless of the name format in email address. Also if the template uses a full name it will make it "Hello FirstName LastName" instead of "Hello LastName, FirstName". Add tests to cover more complex names in the future. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Acked-by: Robin Jarry <robin@jarry.cc>
* parse-links: be more strict with url parsingRobin Jarry2023-06-252-19/+108
| | | | | | | Reuse the same logic than colorize.c to allow parsing markdown links. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
* textinput: fix stemming with multi-byte charsKoni Marti2023-06-221-1/+1
| | | | | | | | | Fix a panic in the textinput when using multi-byte chars in the completions. Fixes: https://todo.sr.ht/~rjarry/aerc/180 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
* msgstore: delete pending headers when done or cancelledTim Culverhouse2023-06-201-1/+2
| | | | | | | | | | | | | | The msgstore keeps a map of UIDs it has requested headers for. The map is only cleared of pending headers when either an error or a valid header is received. This can lead to pending headers not being removed from the list (and therefore never re-requested) if a user has navigated away from the directory before the response is received. Delete the pending headers list if the request is finished or cancelled. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* worker: add context to cancellable requestsTim Culverhouse2023-06-201-11/+19
| | | | | | | | | | | | | Add a Context field to requests which we may want to cancel when changing directories. Add a Cancelled meta-message to inform the UI that a request was cancelled (as opposed to Done or Error). Delete callbacks when a request is Cancelled. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgstore: pass context from dirlist to msgstoreTim Culverhouse2023-06-201-0/+8
| | | | | | | | | | | | | Most, if not all, requests to the worker that may need cancellation are sent by the msgstore. These requests are typically only relevant when the msgstore is the selected one. Pass a context from the dirlister to the msgstore when it is selected. This context will be passed in future commits to worker requests. The context is cancelled when a new directory is selected. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgstore: allocate properly sized mapsTim Culverhouse2023-06-201-3/+2
| | | | | | | | Allocate properly sized maps when receiving a DirectoryContents or DirectoryThreaded message Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* logging: remove ultra verbose trace logsRobin Jarry2023-06-121-3/+1
| | | | | | | | | | | | | | | | | Every message exchanged between the UI and the worker(s) is logged at least twice with some obscure IDs and struct pointer names. When enabling trace logging, this floods the files for very little or no benefit and makes the meaningful logging message hard to catch. Also, other messages tend to flood the output for no specific reason. These are most of the time leftovers from the development process and are not useful for tracking potential issues. Remove these. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* templates: add map functionsRobin Jarry2023-06-102-0/+50
| | | | | | | | | Similar to switch and .StyleSwitch, add map and .StyleMap to work on lists. An extra "exclude" item is available to filter elements out of the list. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
* lib: don't set seen flag upon errorKoni Marti2023-05-281-4/+9
| | | | | | | | | Don't set the Seen flag when an error occurs during opening the message. Fixes: https://todo.sr.ht/~rjarry/aerc/125 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Moritz Poldrack <moritz@poldrack.dev> Acked-by: Robin Jarry <robin@jarry.cc>
* dirstore: list the folders in arrival orderKoni Marti2023-05-283-1/+45
| | | | | | | | | | | | | List the folders in arrival order when dirstore.List() is called instead of returning it in an arbitrary order. If enable-folders-sort=false and dirlist-tree=false, the directory list will arbitrarly reshuffle when changing directories because the dirlist.dirs are generated from keys in a map in the dirstore. Fixes: https://todo.sr.ht/~rjarry/aerc/178 Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* ui: fix deadlocks in message channelRobin Jarry2023-05-204-43/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are several ways the ui message channel can fill up leading to deadlocks. 1) Invalidate() changes the value of uiState to DIRTY. The following call sequence: QueueRedraw() Invalidate() QueueRedraw() Leads to multiple nil messages being queued in the message channel whereas one could assume that the second QueueRedraw() would do nothing. This is caused by the tri-state nature of uiState. 2) We use the same channel to convey state change, keyboard events and redraw requests. Since a keyboard event almost always triggers a redraw, we end up trying to append a redraw message in the same goroutine that reads from the channel. This triggers a deadlock when there are more than 50 pending messages. Solve the issue by using multiple channels, one per type of message that needs to be sent to the main ui thread. Remove QueueRedraw() and merge its functionality in Invalidate(). Only use a DIRTY/CLEAN state to determine if something needs to be queued in the redraw channel. Use a channel for quitting instead of an atomic. Restructure some code functions to have a cleaner API. Use a for loop in the main thread and select from all channels. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Koni Marti <koni.marti@gmail.com> Tested-by: Maarten van Gompel <proycon@anaproy.nl>
* templates: add boolean flagsRobin Jarry2023-05-201-0/+43
| | | | | | | | | | | | | | | | | | Allow accessing email flags via boolean properties instead of having to rely on obscure regular expressions on (.Flags | join ""). With this patch, it is now possible to do this: [ui] index-columns = star:1,name<15%,reply:1,subject,size>=,date>= column-star = {{if .IsFlagged}}★{{end}} column-name = {{if eq .Role "sent"}}{{.To | names | join ", "}}{{else}}{{.From | names | join ", "}}{{end}} column-reply = {{if .IsReplied}}{{end}} column-subject = {{.ThreadPrefix}}{{.Subject}} column-size = {{if .HasAttachment}}📎 {{end}}{{humanReadable .Size}} column-date = {{.DateAutoFormat .Date.Local}} Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Koni Marti <koni.marti@gmail.com>
* templates: use template interface consistentlyKoni Marti2023-05-161-48/+72
| | | | | | | | | | | | | | | Use the template interface consistently. Before, we have exported the state.TemplateData struct and used it in most places instead of the models.TemplateData interface. This lead to some inconsistencies, i.e. Role() has been defined on the exported struct but not on the interface. Unexport the state.TemplateData struct, add a DataSetter interface to set the data needed for the template data and call the Data() method which returns a models.TemplateData interface when the template data is needed. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* textinput: align completion popoverKoni Marti2023-05-161-1/+10
| | | | | | | | Align the completion popover with the actual completion location on the textinput line. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* textinput: improve stemmingKoni Marti2023-05-161-3/+6
| | | | | | | | | | | | | | | | | | | | | | Fix cursor index after stemming and reset it to the position where the completion should occur. Only stem to add more information and not remove any user input. Stemming is activated on the textinput line when the user presses the Tab key. The idea of stemming is to adjust the textinput line to the common ground (="the stem") of the completions options. When the stemmed input line is set, however, the cursor will be moved to the end of the line if there is a text part on the right side of the cursor where the completion should occur. Another Tab press will activate the onStem function again, which then removes the right part of the text input leading to the loss of the user input. This can be prevented by moving the cursor to the place of the completion after stemming. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* commands: expand and complete template codeKoni Marti2023-05-161-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | | Expand and complete template code. The exline does understand template code and can evaluate it. With this patch, the completion systems supports writing the templates by showing the available template data fields and template functions. Pressing <Tab> after }} will show the evaluated template in the completion menu. Complex template code, such as if-else statements work as well. Examples: :filter -f {{<Tab> will show the possible template data fields and functions :filter -f {{index (.To|email) 0}}<Tab> will show the value of the template expression in the completion list Pressing <Tab> twice after a completed template expression will substitute the expression with its value. :{{if match .Folder "INBOX"}}check-mail{{else}}cf INBOX{{end}} Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgstore: fix handling of deleted messagesTim Culverhouse2023-05-111-5/+4
| | | | | | | | | | | | | | | | | | The msgstore trims the uid list when a message was deleted. It does so whether the message is in the message store or not. If the message was already deleted and a MessagesDeleted is received, the store will be trimmed regardless. This can cause spurious emails to be removed from the msgstore due to a race condition with the fs watcher / imap update channel. When a message is deleted, the UI will received two MessagesDeleted and in some cases trim the list, removing too many emails. Fix the handling of deleted messages so that the uid list is rebuilt of all messages except the deleted ones specifically. Reported-by: Drew Devault <sir@cmpwn.com> Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Inwit <inwit@sindominio.net>
* ui: avoid races with queue redrawRobin Jarry2023-04-271-15/+11
| | | | | | | | | | | | | | | | | | When calling ui.QueueRedraw() and a redraw is currently in progress, the redraw int value still holds REDRAW_PENDING since it is updated once the redraw is finished. This can lead to incomplete screen redraws on the embedded terminal. Even changing the redraw value before starting to redraw is exposed to races. Use a single atomic int to represent the state of the UI so that there cannot be any confusion. Rename the constants to make them less confusing. Fixes: b148b94cfe1f ("ui: avoid duplicate queued redraws") Reported-by: Jason Cox <dev@jasoncarloscox.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Jason Cox <dev@jasoncarloscox.com>
* ui: avoid duplicate queued redrawsRobin Jarry2023-04-261-1/+8
| | | | | | | | | No need to queue multiple nil messages to force multiple redraws. Only one is required. When the screen is redrawn, clear the queued redraw flag. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
* mod: drop support for go 1.17Robin Jarry2023-04-241-8/+1
| | | | | | | | | | | | | A lot of libraries are starting to use generics (introduced in go 1.18). Restricting aerc on 1.17 prevents us from updating our dependencies. Since 1.18 is a major milestone, it has a chance to remain supported for a while. Update the minimum go version to 1.18. Run go mod tidy -compat=1.18. Update our CI to run on 1.18. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Bence Ferdinandy <bence@ferdinandy.com>
* directory: add role to template fieldsTim Culverhouse2023-04-221-6/+16
| | | | | | | | | Add .Role as a template field for use in distinguishing between mailboxes with a given IANA role, or custom role defined by aerc ("query" for notmuch queries, for example). Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry<robin@jarry.cc>
* directory: use directory to store rue countsTim Culverhouse2023-04-222-7/+4
| | | | | | | | | | | | Store the Directory RUE counts on the Directory data model. Use DirectoryInfo messages to update the Directory model. Access Directories via the dirlist instead of via the msgstore. Remove unused fields on DirectoryInfo, all backends now give accurate counts. Move refetch logic into dirlist Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry<robin@jarry.cc>
* dirstore: store directory model in dirstoreTim Culverhouse2023-04-221-4/+11
| | | | | | | | Use the dirstore to store models.Directory data structures. This will be used in subsequent commits for accessing directory data. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* listDirectories: refactor listdirectories handlingTim Culverhouse2023-04-221-7/+9
| | | | | | | | | | | | | | | | | ListDirectories is called when connecting, reconnecting, and creation/deletion of a directory. The code is not in the same style as other areas of aerc. Refactor to match coding style of the rest of aerc by creating an Update function which handles necessary updates in the dirlist. This style does not use a callback, making it clearer what is happening in the message flow, and operates similar to how the msgstore receives updates. Use a map in the dirstore to reduce duplicate storage of directory names. Directly add or remove directories from the map when created / deleted to prevent a new ListDirectories message, and a flash of the UI. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
* msgstore: create from types.Directory messageTim Culverhouse2023-04-221-2/+0
| | | | | | | | | | | | | | | Create msgstores when a types.Directory message is received. This removes a quirk from the IMAP worker that msgstores are created on the first DirectoryInfo, and updated on the second. This path requires three messages in order to get an updated message store. By creating from types.Directory, we ensure that any subsequent DirectoryInfo can be routed to a msgstore. Remove the field DirInfo from the msgstore initializer, it isn't needed at initialization and isn't available with this refactor. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>