mirror of
https://git.sr.ht/~sircmpwn/aerc
synced 2024-11-23 08:32:12 +01:00
notmuch: emit LabelList event
This commit is contained in:
parent
2705d8460d
commit
40ceee969b
@ -55,6 +55,23 @@ func (db *DB) connectRO() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListTags lists all known tags
|
||||
func (db *DB) ListTags() ([]string, error) {
|
||||
if db.ro == nil {
|
||||
return nil, fmt.Errorf("not connected to the notmuch db")
|
||||
}
|
||||
tags, err := db.ro.Tags()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result []string
|
||||
var tag *notmuch.Tag
|
||||
for tags.Next(&tag) {
|
||||
result = append(result, tag.Value)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
//getQuery returns a query based on the provided query string.
|
||||
//It also configures the query as specified on the worker
|
||||
func (db *DB) newQuery(query string) (*notmuch.Query, error) {
|
||||
|
@ -153,6 +153,7 @@ func (w *worker) handleConnect(msg *types.Connect) error {
|
||||
return err
|
||||
}
|
||||
w.done(msg)
|
||||
w.emitLabelList()
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -383,6 +384,8 @@ func (w *worker) handleModifyLabels(msg *types.ModifyLabels) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// and update the list of possible tags
|
||||
w.emitLabelList()
|
||||
w.done(msg)
|
||||
return nil
|
||||
}
|
||||
@ -460,6 +463,15 @@ func (w *worker) emitMessageInfo(m *Message,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *worker) emitLabelList() {
|
||||
tags, err := w.db.ListTags()
|
||||
if err != nil {
|
||||
w.w.Logger.Printf("could not load tags: %v", err)
|
||||
return
|
||||
}
|
||||
w.w.PostMessage(&types.LabelList{Labels: tags}, nil)
|
||||
}
|
||||
|
||||
func (w *worker) sort(uids []uint32,
|
||||
criteria []*types.SortCriterion) ([]uint32, error) {
|
||||
if len(criteria) == 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user