diff options
author | Koni Marti <koni.marti@gmail.com> | 2024-08-07 20:52:35 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-08-20 12:26:47 +0200 |
commit | dedf7b58037651f3d63a78fc25bd9b319cbaa374 (patch) | |
tree | 23516108931d9d71ed2d01c4425edb5ec0cef26f /app | |
parent | d0be49b932dc2d728cd7ecc4c1c22faf470d771a (diff) | |
download | aerc-dedf7b58037651f3d63a78fc25bd9b319cbaa374.tar.gz |
account: update split views
Update split views on reload. Use the safe acct.SelectedMessage()
instead of acct.msglist.Selected() which can panic if msglist.store is
nil.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Inwit <inwit@sindominio.net>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'app')
-rw-r--r-- | app/account.go | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/app/account.go b/app/account.go index ffc7f146..2f9cdf99 100644 --- a/app/account.go +++ b/app/account.go @@ -114,6 +114,19 @@ func (acct *AccountView) Configure() { } acct.grid.AddChild(acct.msglist).At(0, 1) acct.setTitle() + + // handle splits + if acct.split != nil { + acct.split.Close() + } + splitDirection := acct.splitDir + acct.splitDir = config.SPLIT_NONE + switch splitDirection { + case config.SPLIT_HORIZONTAL: + acct.Split(acct.SplitSize()) + case config.SPLIT_VERTICAL: + acct.Vsplit(acct.SplitSize()) + } } func (acct *AccountView) SetStatus(setters ...state.SetStateFunc) { @@ -675,7 +688,11 @@ func (acct *AccountView) Split(n int) { acct.grid.AddChild(ui.NewBordered(acct.msglist, ui.BORDER_BOTTOM, acct.UiConfig())).At(0, 1) acct.split = NewMessageViewer(acct, nil) acct.grid.AddChild(acct.split).At(1, 1) - acct.updateSplitView(acct.msglist.Selected()) + msg, err := acct.SelectedMessage() + if err != nil { + log.Debugf("split: load message error: %v", err) + } + acct.updateSplitView(msg) } // Vsplit splits the message list view vertically. The message list will be n @@ -700,7 +717,11 @@ func (acct *AccountView) Vsplit(n int) { acct.grid.AddChild(ui.NewBordered(acct.msglist, ui.BORDER_RIGHT, acct.UiConfig())).At(0, 1) acct.split = NewMessageViewer(acct, nil) acct.grid.AddChild(acct.split).At(0, 2) - acct.updateSplitView(acct.msglist.Selected()) + msg, err := acct.SelectedMessage() + if err != nil { + log.Debugf("split: load message error: %v", err) + } + acct.updateSplitView(msg) } // setTitle executes the title template and sets the tab title |