From 7417df0f3ca20d6fcc0ef6ecb122dacf2afd741f Mon Sep 17 00:00:00 2001 From: Ville Ranki Date: Thu, 18 Oct 2018 17:02:38 +0300 Subject: Alt-a to jump to next channel with unread messages. --- ui/room-list.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'ui/room-list.go') diff --git a/ui/room-list.go b/ui/room-list.go index a7543a9..6b81e60 100644 --- a/ui/room-list.go +++ b/ui/room-list.go @@ -21,6 +21,7 @@ import ( "strings" "math" + "maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/matrix/rooms" "maunium.net/go/tcell" @@ -313,6 +314,27 @@ func (list *RoomList) Next() (string, *rooms.Room) { return list.Last() } +// NextWithActivity Returns next room with activity. +// +// Sorted by (in priority): +// +// - Highlights +// - Messages +// - Other traffic (joins, parts, etc) +// +// TODO: Sorting. Now just finds first room with new messages. +func (list *RoomList) NextWithActivity() (string, *rooms.Room) { + for tag, trl := range list.items { + for _, room := range trl.All() { + if room.HasNewMessages() { + return tag, room.Room + } + } + } + // No room with activity found + return "", nil +} + func (list *RoomList) index(tag string, room *rooms.Room) int { tagIndex := list.IndexTag(tag) if tagIndex == -1 { -- cgit v1.2.3