aboutsummaryrefslogtreecommitdiffstats
path: root/app/msglist.go
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 /app/msglist.go
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 'app/msglist.go')
-rw-r--r--app/msglist.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/app/msglist.go b/app/msglist.go
index 9e6f3289..4db54f4d 100644
--- a/app/msglist.go
+++ b/app/msglist.go
@@ -44,7 +44,7 @@ func (ml *MessageList) Invalidate() {
}
type messageRowParams struct {
- uid uint32
+ uid models.UID
needsHeaders bool
err error
uiConfig *config.UIConfig
@@ -61,7 +61,7 @@ func (ml *MessageList) AlignMessage(pos AlignPosition) {
idx := 0
iter := store.UidsIterator()
for i := 0; iter.Next(); i++ {
- if store.SelectedUid() == iter.Value().(uint32) {
+ if store.SelectedUid() == iter.Value().(models.UID) {
idx = i
break
}
@@ -92,7 +92,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
ml.UpdateScroller(ml.height, len(store.Uids()))
iter := store.UidsIterator()
for i := 0; iter.Next(); i++ {
- if store.SelectedUid() == iter.Value().(uint32) {
+ if store.SelectedUid() == iter.Value().(models.UID) {
ml.EnsureScroll(i)
break
}
@@ -108,7 +108,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
return
}
- var needsHeaders []uint32
+ var needsHeaders []models.UID
data := state.NewDataSetter()
data.SetAccount(acct.acct)
@@ -166,7 +166,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
if i < ml.Scroll() {
continue
}
- uid := iter.Value().(uint32)
+ uid := iter.Value().(models.UID)
if showThreads {
threadView.Update(data, uid)
}
@@ -201,7 +201,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
}
func addMessage(
- store *lib.MessageStore, uid uint32,
+ store *lib.MessageStore, uid models.UID,
table *ui.Table, data state.DataSetter,
uiConfig *config.UIConfig,
) bool {
@@ -406,14 +406,14 @@ func (ml *MessageList) Select(index int) {
iter := store.UidsIterator()
- var uid uint32
+ var uid models.UID
if index < 0 {
uid = uids[iter.EndIndex()]
} else {
uid = uids[iter.StartIndex()]
for i := 0; iter.Next(); i++ {
if i >= index {
- uid = iter.Value().(uint32)
+ uid = iter.Value().(models.UID)
break
}
}
@@ -579,7 +579,7 @@ func newThreadView(store *lib.MessageStore) *threadView {
}
}
-func (t *threadView) Update(data state.DataSetter, uid uint32) {
+func (t *threadView) Update(data state.DataSetter, uid models.UID) {
thread, err := t.store.Thread(uid)
info := state.ThreadInfo{}
if thread != nil && err == nil {