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 /commands | |
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 'commands')
-rw-r--r-- | commands/account/import-mbox.go | 2 | ||||
-rw-r--r-- | commands/compose/postpone.go | 2 | ||||
-rw-r--r-- | commands/compose/send.go | 2 | ||||
-rw-r--r-- | commands/msg/read.go | 11 |
4 files changed, 5 insertions, 12 deletions
diff --git a/commands/account/import-mbox.go b/commands/account/import-mbox.go index 7dab1958..b03d8d78 100644 --- a/commands/account/import-mbox.go +++ b/commands/account/import-mbox.go @@ -84,7 +84,7 @@ func (ImportMbox) Execute(aerc *widgets.Aerc, args []string) error { nbytes, _ := io.Copy(&buf, r) worker.PostAction(&types.AppendMessage{ Destination: folder, - Flags: []models.Flag{models.SeenFlag}, + Flags: models.SeenFlag, Date: time.Now(), Reader: &buf, Length: int(nbytes), diff --git a/commands/compose/postpone.go b/commands/compose/postpone.go index eb7bc0a3..cc709ff7 100644 --- a/commands/compose/postpone.go +++ b/commands/compose/postpone.go @@ -95,7 +95,7 @@ func (Postpone) Execute(aerc *widgets.Aerc, args []string) error { nbytes := int(ctr.Count()) worker.PostAction(&types.AppendMessage{ Destination: config.Postpone, - Flags: []models.Flag{models.SeenFlag}, + Flags: models.SeenFlag, Date: time.Now(), Reader: &buf, Length: int(nbytes), diff --git a/commands/compose/send.go b/commands/compose/send.go index c5f4be3b..4c2b0503 100644 --- a/commands/compose/send.go +++ b/commands/compose/send.go @@ -502,7 +502,7 @@ func copyToSent(worker *types.Worker, dest string, errCh := make(chan error) worker.PostAction(&types.AppendMessage{ Destination: dest, - Flags: []models.Flag{models.SeenFlag}, + Flags: models.SeenFlag, Date: time.Now(), Reader: msg, Length: n, diff --git a/commands/msg/read.go b/commands/msg/read.go index 878dc3c8..cffd2218 100644 --- a/commands/msg/read.go +++ b/commands/msg/read.go @@ -34,7 +34,7 @@ func (FlagMsg) Complete(aerc *widgets.Aerc, args []string) []string { // 'flag' or 'unflag', respectively, but the 'Seen' flag is affected. func (FlagMsg) Execute(aerc *widgets.Aerc, args []string) error { // The flag to change - var flag models.Flag + var flag models.Flags // User-readable name of the flag to change var flagName string // Whether to toggle the flag (true) or to enable/disable it (false) @@ -130,14 +130,7 @@ func (FlagMsg) Execute(aerc *widgets.Aerc, args []string) error { return err } for _, m := range msgs { - var enabled bool - for _, mFlag := range m.Flags { - if mFlag == flag { - enabled = true - break - } - } - if enabled { + if m.Flags.Has(flag) { toDisable = append(toDisable, m.Uid) } else { toEnable = append(toEnable, m.Uid) |