Feature/signatures and folders per account#19
Conversation
|
Love it, thank you so much ! I'm a little short in time, but I will def. merge that |
Take your time! You may want to have a look at the last commit. I thought it was a bug but I think you did that intentionally. However, the behavior was a bit odd, it was showing it was in Drafts while the inbox content was displayed. |
Ahh yes, that was intentional that I think it's a bit hidden, tough once you know, or check the |
…to resolve the Signature either from the account or the UI. Replaced the calls to the signature in model.go
…sh/Drafts/Spam. Added Config.ResolveFolders to merge the account block onto the global folders field-by-field. Added unit tests pinning the field-by-field semantics.
…Added sentDraftsIMAPAccount() as a single resolver for the account whose Sent/Drafts mailboxes receive a send or draft save, so the IMAP client and the folder name can never drift apart under per-account folder configs. Removed the now-unused sentDraftsIMAPClient and presendIMAPClient wrappers.
…pam/Trash moves, screener classifications, batch delete, and folder-comparison checks now use the active account's folder names so per-account overrides take effect. Made activeAccount() safe against zero-account Models so the new per-account lookups don't panic in unit tests that hand-build minimal models.
…older() now returns the per-account IMAP mailbox name for the active account so the existing Sent/Trash/isDraft comparisons resolve correctly under per-account overrides. Migrated the M-chord bulk move map, gS/gd jump chords, the :go-spam cmdline command, and the newInboxList constructor's Sent/Drafts strings. Added a test pinning activeFolder() per-account override behavior. Inbox list delegate still bakes Sent/Drafts at construction time and is not refreshed on account switch — pending follow-up.
…nt/Drafts folder names take effect. Added emailDelegateForActiveAccount() that builds the row-rendering delegate from the active account's resolved folder names, and refreshInboxDelegate() that swaps it into the list. Wired the refresh into the ctrl+a handler. Without this, viewing Sent/Drafts on a non-default account showed the sender instead of the recipient because the delegate still held the initial account's folder names. Added a unit test pinning the delegate-construction logic.
5bd8f2e to
a79add1
Compare
What is it about
Support per account overrides of signatures and folders.
Signatures
This aims to support #16.
Config
A new block is supported under
[[accounts]]called[accounts.signature_block]. If present, it will override the default signature block under[ui]and the legacy signature.Example:
New signature resolver method
A new method to resolve the signature is added to Config:
It returns a
SignatureConfigwith bothtextandhtmlso the caller can decide which one to use.Because account signature depends on the active account, the caller must pass the current active account.
The previous methods created in the
UIto get the signature have been removed as this is covered directly by the newConfig.Signaturemethod.Callers replacement
All the callers exist in
model.go. These have been refactored to use the newSignaturemethod.Testing
I have added additional test cases to cover the resolution of the signature as well as the fall back to defaults.
Breaking changes
None. It fully supports previous configurations.
Folders
This supports overriding the name of the folders per-account. This feature is required due to the different naming between IMAP providers like Gmail using tags or Microsoft calling
SentfolderSent Itemsinstead. When using multiple accounts, this is an issue.This has been a bit more complex change due to two key points:
Config file
A new block is supported under
[[accounts]]called[accounts.folders]. If present, it will override the default[folders]for any specific folder defined. Currently only the following folders are possible to override:Example:
New Folders type and folders resolver method
A new type was created to represent the folders supported under the
AccountConfig:Additionally a new method is created under
Configto resolve the folders for the account:This resolver, given the account, will read the
[folders]block and then override any folder that has been defined under[accounts.folders].Callers replacement
This is quite a wide change given that folders are referenced in many places. I'll explain below the approach to this:
ResolveFolders(), as an example,activeFolder().M,gXmotions as well as:go-commands have been refactored to go through the resolver.saveDraftCmdis modified to takeconfig.AccountConfiginstead of*imap.ClientTesting
I have covered all the folders affected and callers to make sure nothing breaks. Additionally ran smoke tests with two accounts and different folders setup. All seem OK but I'd appreciate to double check.
Breaking changes
None. Previous configuration is fully supported.
Notes
Fixed a small bug in the
activeFolder()tab-labels. Drafts were missing.