aboutsummaryrefslogtreecommitdiffstats
path: root/commands/account
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2024-08-14 16:59:11 +0200
committerRobin Jarry <robin@jarry.cc>2024-08-28 12:06:01 +0200
commit73dc39c6ee0827fc68b93af8dc438b0e1c14e929 (patch)
treeaff067600ea6326ff179447ed968b6712013b889 /commands/account
parent2950d919a5c5a55bd0eb53d6c41f989d8b70bd55 (diff)
downloadaerc-73dc39c6ee0827fc68b93af8dc438b0e1c14e929.tar.gz
treewide: replace uint32 uids with opaque strings
Add a new models.UID type (an alias to string). Replace all occurrences of uint32 being used as message UID or thread UID with models.UID. Update all workers to only expose models.UID values and deal with the conversion internally. Only IMAP needs to convert these to uint32. All other backends already use plain strings as message identifiers, in which case no conversion is even needed. The directory tree implementation needed to be heavily refactored in order to accommodate thread UID not being usable as a list index. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'commands/account')
-rw-r--r--commands/account/clear.go2
-rw-r--r--commands/account/export-mbox.go19
-rw-r--r--commands/account/next.go2
-rw-r--r--commands/account/search.go2
4 files changed, 13 insertions, 12 deletions
diff --git a/commands/account/clear.go b/commands/account/clear.go
index 1c13ddf5..ec033c46 100644
--- a/commands/account/clear.go
+++ b/commands/account/clear.go
@@ -35,7 +35,7 @@ func (c Clear) Execute(args []string) error {
}
if c.Selected {
- defer store.Select(0)
+ defer store.Select("")
}
store.ApplyClear()
acct.SetStatus(state.SearchFilterClear())
diff --git a/commands/account/export-mbox.go b/commands/account/export-mbox.go
index 6422eae0..619c24a2 100644
--- a/commands/account/export-mbox.go
+++ b/commands/account/export-mbox.go
@@ -13,6 +13,7 @@ import (
"git.sr.ht/~rjarry/aerc/lib"
"git.sr.ht/~rjarry/aerc/lib/log"
"git.sr.ht/~rjarry/aerc/lib/xdg"
+ "git.sr.ht/~rjarry/aerc/models"
mboxer "git.sr.ht/~rjarry/aerc/worker/mbox"
"git.sr.ht/~rjarry/aerc/worker/types"
)
@@ -61,7 +62,7 @@ func (e ExportMbox) Execute(args []string) error {
app.PushStatus("Exporting to "+e.Filename, 10*time.Second)
// uids of messages to export
- var uids []uint32
+ var uids []models.UID
// check if something is marked - we export that then
msgProvider, ok := app.SelectedTabContent().(app.ProvidesMessages)
@@ -98,7 +99,7 @@ func (e ExportMbox) Execute(args []string) error {
defer file.Close()
var mu sync.Mutex
- var ctr uint32
+ var ctr uint
var retries int
done := make(chan bool)
@@ -159,15 +160,15 @@ func (e ExportMbox) Execute(args []string) error {
return nil
}
-func sortMarkedUids(marked []uint32, store *lib.MessageStore) ([]uint32, error) {
- lookup := map[uint32]bool{}
+func sortMarkedUids(marked []models.UID, store *lib.MessageStore) ([]models.UID, error) {
+ lookup := map[models.UID]bool{}
for _, uid := range marked {
lookup[uid] = true
}
- uids := []uint32{}
+ uids := []models.UID{}
iter := store.UidsIterator()
for iter.Next() {
- uid, ok := iter.Value().(uint32)
+ uid, ok := iter.Value().(models.UID)
if !ok {
return nil, errors.New("Invalid message UID value")
}
@@ -179,11 +180,11 @@ func sortMarkedUids(marked []uint32, store *lib.MessageStore) ([]uint32, error)
return uids, nil
}
-func sortAllUids(store *lib.MessageStore) ([]uint32, error) {
- uids := []uint32{}
+func sortAllUids(store *lib.MessageStore) ([]models.UID, error) {
+ uids := []models.UID{}
iter := store.UidsIterator()
for iter.Next() {
- uid, ok := iter.Value().(uint32)
+ uid, ok := iter.Value().(models.UID)
if !ok {
return nil, errors.New("Invalid message UID value")
}
diff --git a/commands/account/next.go b/commands/account/next.go
index e14b14fb..b54ed0c1 100644
--- a/commands/account/next.go
+++ b/commands/account/next.go
@@ -85,7 +85,7 @@ func (np NextPrevMsg) Execute(args []string) error {
if nextMsg := store.Selected(); nextMsg != nil {
reloadViewer(nextMsg)
} else {
- store.FetchHeaders([]uint32{store.SelectedUid()},
+ store.FetchHeaders([]models.UID{store.SelectedUid()},
func(msg types.WorkerMessage) {
if m, ok := msg.(*types.MessageInfo); ok {
reloadViewer(m.Info)
diff --git a/commands/account/search.go b/commands/account/search.go
index 5c2eaec7..14aa367b 100644
--- a/commands/account/search.go
+++ b/commands/account/search.go
@@ -191,7 +191,7 @@ func (s SearchFilter) Execute(args []string) error {
store.Sort(store.GetCurrentSortCriteria(), cb)
} else {
acct.SetStatus(state.Search("Searching..."))
- cb := func(uids []uint32) {
+ cb := func(uids []models.UID) {
acct.SetStatus(state.Search(strings.Join(args, " ")))
log.Tracef("Search results: %v", uids)
store.ApplySearch(uids)