From 1eb132a589affaa17d9c7cdd3c5999fce019f0e9 Mon Sep 17 00:00:00 2001 From: FIGBERT Date: Tue, 7 Mar 2023 14:11:08 -0800 Subject: [PATCH] Add RoomView previews to roster view --- config/keybindings.yaml | 1 + ui/view-roster.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/config/keybindings.yaml b/config/keybindings.yaml index befa824..e3dae68 100644 --- a/config/keybindings.yaml +++ b/config/keybindings.yaml @@ -22,6 +22,7 @@ roster: 'Up': prev_room 'Escape': clear 'q': quit + 'Enter': enter modal: 'Tab': select_next diff --git a/ui/view-roster.go b/ui/view-roster.go index 793ce65..23e66f6 100644 --- a/ui/view-roster.go +++ b/ui/view-roster.go @@ -35,6 +35,7 @@ type RosterView struct { rooms []*rooms.Room height, width int + focused bool parent *MainView } @@ -108,6 +109,14 @@ func (rstr *RosterView) getMostRecentMessage(room *rooms.Room) (string, bool) { } func (rstr *RosterView) Draw(screen mauview.Screen) { + if rstr.focused { + if roomView, ok := rstr.parent.getRoomView(rstr.selected.ID, true); ok { + roomView.Update() + roomView.Draw(screen) + return + } + } + rstr.width, rstr.height = screen.Size() titleStyle := tcell.StyleDefault.Foreground(tcell.ColorDefault).Bold(true) @@ -197,9 +206,12 @@ func (rstr *RosterView) OnKeyEvent(event mauview.KeyEvent) bool { rstr.selected = rstr.rooms[index-1] } case "clear": + rstr.focused = false rstr.selected = nil case "quit": rstr.parent.gmx.Stop(true) + case "enter": + rstr.focused = rstr.selected != nil default: return false }