aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-04-25 07:01:00 +0300
committerTulir Asokan <tulir@maunium.net>2018-04-25 00:42:05 +0300
commit576bab9e2e9589942d4cac8742fa1b54e8b237f9 (patch)
treedaea2d011127c00a254182bd957d2e5fe93fe9aa
parent3de07ad550776a57e96399660c0ccd9c58dafcf3 (diff)
Fix People tag
-rw-r--r--ui/room-list.go18
-rw-r--r--ui/view-main.go4
2 files changed, 15 insertions, 7 deletions
diff --git a/ui/room-list.go b/ui/room-list.go
index 9444313..1cb71c9 100644
--- a/ui/room-list.go
+++ b/ui/room-list.go
@@ -58,7 +58,7 @@ func NewRoomList() *RoomList {
return &RoomList{
Box: tview.NewBox(),
items: make(map[string][]*rooms.Room),
- tags: []string{"m.favourite", "im.vector.fake.direct", "", "m.lowpriority"},
+ tags: []string{"m.favourite", "net.maunium.gomuks.fake.direct", "", "m.lowpriority"},
mainTextColor: tcell.ColorWhite,
selectedTextColor: tcell.ColorWhite,
@@ -102,6 +102,9 @@ func (list *RoomList) CheckTag(tag string) {
}
func (list *RoomList) AddToTag(tag string, room *rooms.Room) {
+ if tag == "" && len(room.GetMembers()) == 2 {
+ tag = "net.maunium.gomuks.fake.direct"
+ }
items, ok := list.items[tag]
if !ok {
list.items[tag] = []*rooms.Room{room}
@@ -214,7 +217,7 @@ func (list *RoomList) Clear() {
func (list *RoomList) SetSelected(tag string, room *rooms.Room) {
list.selected = room
list.selectedTag = tag
- debug.Print("Selecting", room.GetTitle(), "in", tag)
+ debug.Print("Selecting", room.GetTitle(), "in", list.GetTagDisplayName(tag))
}
func (list *RoomList) HasSelected() bool {
@@ -356,10 +359,8 @@ func (list *RoomList) GetTagDisplayName(tag string) string {
return "Favorites"
case tag == "m.lowpriority":
return "Low Priority"
- case tag == "im.vector.fake.direct":
+ case tag == "net.maunium.gomuks.fake.direct":
return "People"
- case strings.HasPrefix(tag, "m."):
- return strings.Title(strings.Replace(tag[len("m."):], "_", " ", -1))
case strings.HasPrefix(tag, "u."):
return tag[len("u."):]
case !nsRegex.MatchString(tag):
@@ -386,7 +387,12 @@ func (list *RoomList) Draw(screen tcell.Screen) {
// Draw the list items.
for _, tag := range list.tags {
items := list.items[tag]
- widget.WriteLine(screen, tview.AlignLeft, list.GetTagDisplayName(tag), x, y, width, tcell.StyleDefault.Underline(true).Bold(true))
+ tagDisplayName := list.GetTagDisplayName(tag)
+ if len(tagDisplayName) == 0 {
+ continue
+ }
+
+ widget.WriteLine(screen, tview.AlignLeft, tagDisplayName, x, y, width, tcell.StyleDefault.Underline(true).Bold(true))
y++
for i := len(items) - 1; i >= 0; i-- {
item := items[i]
diff --git a/ui/view-main.go b/ui/view-main.go
index d20fed3..4b01829 100644
--- a/ui/view-main.go
+++ b/ui/view-main.go
@@ -67,6 +67,7 @@ func (ui *GomuksUI) NewMainView() tview.Primitive {
mainView.AddItem(mainView.roomList, 25, 0, false)
mainView.AddItem(widget.NewBorder(), 1, 0, false)
mainView.AddItem(mainView.roomView, 0, 1, true)
+ mainView.BumpFocus()
ui.mainView = mainView
@@ -398,6 +399,7 @@ func sendNotification(room *rooms.Room, sender, text string, critical, sound boo
if room.GetTitle() != sender {
sender = fmt.Sprintf("%s (%s)", sender, room.GetTitle())
}
+ debug.Printf("Sending notification with body \"%s\" from %s in room ID %s (critical=%v, sound=%v)", text, sender, room.ID, critical, sound)
notification.Send(sender, text, critical, sound)
}
@@ -405,7 +407,7 @@ func (view *MainView) NotifyMessage(room *rooms.Room, message ifc.Message, shoul
// Whether or not the room where the message came is the currently shown room.
isCurrent := room == view.roomList.SelectedRoom()
// Whether or not the terminal window is focused.
- isFocused := view.lastFocusTime.Add(30 * time.Second).Before(time.Now())
+ isFocused := time.Now().Add(-30 * time.Second).Before(view.lastFocusTime)
// Whether or not the push rules say this message should be notified about.
shouldNotify := (should.Notify || !should.NotifySpecified) && message.Sender() != view.config.Session.UserID