| 1 |
package msg |
| 2 |
|
| 3 |
import ( |
| 4 |
"git.sr.ht/~rjarry/aerc/commands" |
| 5 |
"git.sr.ht/~rjarry/aerc/lib/state" |
| 6 |
"git.sr.ht/~rjarry/aerc/lib/ui" |
| 7 |
) |
| 8 |
|
| 9 |
type ToggleThreads struct{} |
| 10 |
|
| 11 |
func init() { |
| 12 |
commands.Register(ToggleThreads{}) |
| 13 |
} |
| 14 |
|
| 15 |
func (ToggleThreads) Description() string { |
| 16 |
return "Toggle between message threading and the normal message list." |
| 17 |
} |
| 18 |
|
| 19 |
func (ToggleThreads) Context() commands.CommandContext { |
| 20 |
return commands.MESSAGE_LIST | commands.MESSAGE_VIEWER |
| 21 |
} |
| 22 |
|
| 23 |
func (ToggleThreads) Aliases() []string { |
| 24 |
return []string{"toggle-threads"} |
| 25 |
} |
| 26 |
|
| 27 |
func (ToggleThreads) Execute(args []string) error { |
| 28 |
h := newHelper() |
| 29 |
acct, err := h.account() |
| 30 |
if err != nil { |
| 31 |
return err |
| 32 |
} |
| 33 |
store, err := h.store() |
| 34 |
if err != nil { |
| 35 |
return err |
| 36 |
} |
| 37 |
store.SetThreadedView(!store.ThreadedView()) |
| 38 |
acct.SetStatus(state.Threading(store.ThreadedView())) |
| 39 |
ui.Invalidate() |
| 40 |
return nil |
| 41 |
} |