From 0aab8ac318f6dee479afba13d09a5d1d1c0baa91 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Thu, 25 Jan 2024 08:25:49 -0500 Subject: notmuch: centralize flag/tag mappings Mimic other backends that have centralized mappings. Doing so makes adding support for the draft flag simpler in a subsequent commit. Signed-off-by: Jason Cox Acked-by: Robin Jarry --- worker/notmuch/search.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'worker/notmuch/search.go') diff --git a/worker/notmuch/search.go b/worker/notmuch/search.go index b3592d41..36d4c2df 100644 --- a/worker/notmuch/search.go +++ b/worker/notmuch/search.go @@ -67,7 +67,7 @@ func translate(crit *types.SearchCriteria) string { } // flags - for _, f := range []models.Flags{models.SeenFlag, models.AnsweredFlag, models.FlaggedFlag} { + for f := range flagToTag { if crit.WithFlags.Has(f) { base.and(getParsedFlag(f, false)) } @@ -100,17 +100,8 @@ func translate(crit *types.SearchCriteria) string { } func getParsedFlag(flag models.Flags, inverse bool) string { - name := "" - switch flag { - case models.AnsweredFlag: - name = "tag:replied" - case models.SeenFlag: - name = "tag:unread" - inverse = !inverse - case models.FlaggedFlag: - name = "tag:flagged" - } - if inverse { + name := "tag:" + flagToTag[flag] + if flagToInvert[flag] { name = "not " + name } return name -- cgit