aboutsummaryrefslogtreecommitdiff
path: root/ui/room-list.go
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-11-14 00:01:20 +0200
committerTulir Asokan <tulir@maunium.net>2018-11-14 00:01:20 +0200
commit7651e84be949ecabac62d21b6e843b6776a2371e (patch)
tree15babd86e895b3f2cf0f74c8ebba66137fd2a791 /ui/room-list.go
parentba387764ca1590625d349e74eb8a8a64d1849b67 (diff)
parent61400188bb6c3c86c40a8be8242450d45e764415 (diff)
Merge branch 'master' into update
Diffstat (limited to 'ui/room-list.go')
-rw-r--r--ui/room-list.go22
1 files changed, 22 insertions, 0 deletions
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 {