store: extract marking behavior and add tests
Separate the marking functions from the message store and extract the marking behavior into its own class with tests. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
ee961d3b1d
commit
cfc19a7ec2
14 changed files with 373 additions and 177 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"git.sr.ht/~rjarry/aerc/config"
|
||||
"git.sr.ht/~rjarry/aerc/lib"
|
||||
"git.sr.ht/~rjarry/aerc/lib/marker"
|
||||
"git.sr.ht/~rjarry/aerc/lib/sort"
|
||||
"git.sr.ht/~rjarry/aerc/lib/statusline"
|
||||
"git.sr.ht/~rjarry/aerc/lib/ui"
|
||||
|
@ -222,8 +223,10 @@ func (acct *AccountView) SelectedMessage() (*models.MessageInfo, error) {
|
|||
}
|
||||
|
||||
func (acct *AccountView) MarkedMessages() ([]uint32, error) {
|
||||
store := acct.Store()
|
||||
return store.Marked(), nil
|
||||
if store := acct.Store(); store != nil {
|
||||
return store.Marker().Marked(), nil
|
||||
}
|
||||
return nil, errors.New("no store available")
|
||||
}
|
||||
|
||||
func (acct *AccountView) SelectedMessagePart() *PartInfo {
|
||||
|
@ -301,6 +304,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
|
|||
acct.host.Beep()
|
||||
}
|
||||
})
|
||||
store.SetMarker(marker.New(store))
|
||||
acct.dirlist.SetMsgStore(msg.Info.Name, store)
|
||||
}
|
||||
case *types.DirectoryContents:
|
||||
|
|
|
@ -122,7 +122,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
|
|||
AccountName: acct.Name(),
|
||||
MsgInfo: msg,
|
||||
MsgNum: row,
|
||||
MsgIsMarked: store.IsMarked(t.Uid),
|
||||
MsgIsMarked: store.Marker().IsMarked(t.Uid),
|
||||
ThreadPrefix: prefix,
|
||||
ThreadSameSubject: normalizedSubject == lastSubject,
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ func (ml *MessageList) Draw(ctx *ui.Context) {
|
|||
AccountName: acct.Name(),
|
||||
MsgInfo: msg,
|
||||
MsgNum: row,
|
||||
MsgIsMarked: store.IsMarked(uid),
|
||||
MsgIsMarked: store.Marker().IsMarked(uid),
|
||||
}
|
||||
if ml.drawRow(textWidth, ctx, uid, row, &needsHeaders, fmtCtx) {
|
||||
break
|
||||
|
@ -244,7 +244,7 @@ func (ml *MessageList) drawRow(textWidth int, ctx *ui.Context, uid uint32, row i
|
|||
}
|
||||
|
||||
// marked message
|
||||
if store.IsMarked(msg.Uid) {
|
||||
if store.Marker().IsMarked(msg.Uid) {
|
||||
msg_styles = append(msg_styles, config.STYLE_MSGLIST_MARKED)
|
||||
}
|
||||
|
||||
|
|
|
@ -302,8 +302,7 @@ func (mv *MessageViewer) SelectedMessage() (*models.MessageInfo, error) {
|
|||
}
|
||||
|
||||
func (mv *MessageViewer) MarkedMessages() ([]uint32, error) {
|
||||
store := mv.Store()
|
||||
return store.Marked(), nil
|
||||
return mv.acct.MarkedMessages()
|
||||
}
|
||||
|
||||
func (mv *MessageViewer) ToggleHeaders() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue