diff options
author | Robin Jarry <robin@jarry.cc> | 2022-12-21 11:31:04 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-01-04 22:57:31 +0100 |
commit | 5677f93ff8e0f212be112a110fcfe09663c84f98 (patch) | |
tree | 9f47f430b312d1f0dc1acdd3735cfd76ad21e0f0 /lib/msgstore.go | |
parent | 36fded03e762da97edde61559c8bf60d5749d6a2 (diff) | |
download | aerc-5677f93ff8e0f212be112a110fcfe09663c84f98.tar.gz |
model: change flags array to bitmask
Using a list of integers is not optimal. Use a bit mask instead.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'lib/msgstore.go')
-rw-r--r-- | lib/msgstore.go | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/msgstore.go b/lib/msgstore.go index 8b2d0419..d2851db2 100644 --- a/lib/msgstore.go +++ b/lib/msgstore.go @@ -269,15 +269,8 @@ func (store *MessageStore) Update(msg types.WorkerMessage) { store.Unlock() store.fetchFlags() } - seen := false - recent := false - for _, flag := range msg.Info.Flags { - if flag == models.RecentFlag { - recent = true - } else if flag == models.SeenFlag { - seen = true - } - } + seen := msg.Info.Flags.Has(models.RecentFlag) + recent := msg.Info.Flags.Has(models.SeenFlag) if !seen && recent { store.triggerNewEmail(msg.Info) } @@ -563,12 +556,12 @@ func (store *MessageStore) Move(uids []uint32, dest string, createDest bool, }) } -func (store *MessageStore) Flag(uids []uint32, flag models.Flag, +func (store *MessageStore) Flag(uids []uint32, flags models.Flags, enable bool, cb func(msg types.WorkerMessage), ) { store.worker.PostAction(&types.FlagMessages{ Enable: enable, - Flag: flag, + Flags: flags, Uids: uids, }, cb) } |