aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-10-18 17:09:37 +0300
committerGitHub <noreply@github.com>2018-10-18 17:09:37 +0300
commit61400188bb6c3c86c40a8be8242450d45e764415 (patch)
tree98b4c7fb045183c9af7062bba1d53c4e4be7dfab
parente0e2b4f2f14bea1453ff54de12eecec4c7d70f04 (diff)
parent7417df0f3ca20d6fcc0ef6ecb122dacf2afd741f (diff)
Merge pull request #74 from vranki/feature/alt-a
Alt-a to jump to next channel with unread messages.
-rw-r--r--ui/room-list.go22
-rw-r--r--ui/tag-room-list.go5
-rw-r--r--ui/view-main.go2
3 files changed, 27 insertions, 2 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 {
diff --git a/ui/tag-room-list.go b/ui/tag-room-list.go
index 2705c49..60b4350 100644
--- a/ui/tag-room-list.go
+++ b/ui/tag-room-list.go
@@ -18,12 +18,13 @@ package ui
import (
"fmt"
+ "strconv"
+ "strings"
+
"maunium.net/go/gomuks/matrix/rooms"
"maunium.net/go/gomuks/ui/widget"
"maunium.net/go/tcell"
"maunium.net/go/tview"
- "strconv"
- "strings"
)
type OrderedRoom struct {
diff --git a/ui/view-main.go b/ui/view-main.go
index f38043a..8bd0668 100644
--- a/ui/view-main.go
+++ b/ui/view-main.go
@@ -196,6 +196,8 @@ func (view *MainView) KeyEventHandler(roomView *RoomView, key *tcell.EventKey) *
searchModal := NewFuzzySearchModal(view, 42, 12)
view.parent.views.AddPage("fuzzy-search-modal", searchModal, true, true)
view.parent.app.SetFocus(searchModal)
+ case c == 'a':
+ view.SwitchRoom(view.roomList.NextWithActivity())
case c == 'l':
view.ShowBare(roomView)
default: