aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-05-16 21:42:07 +0300
committerTulir Asokan <tulir@maunium.net>2018-05-16 21:42:07 +0300
commit512ca88804268bf58a754e8a02be556f953db317 (patch)
treee5b6980661bde6ec1cbcfed1f16f040bea2be2f0
parenta8a4c72d14027afa669fd7c85ea3a48bde8a3924 (diff)
Fix notifications about own messages
-rw-r--r--interface/ui.go2
-rw-r--r--ui/messages/message.go1
-rw-r--r--ui/messages/meta.go4
-rw-r--r--ui/view-main.go7
4 files changed, 11 insertions, 3 deletions
diff --git a/interface/ui.go b/interface/ui.go
index 6023953..7e181d8 100644
--- a/interface/ui.go
+++ b/interface/ui.go
@@ -117,4 +117,6 @@ type Message interface {
SetState(state MessageState)
State() MessageState
+
+ SenderID() string
}
diff --git a/ui/messages/message.go b/ui/messages/message.go
index 637e8eb..790ae8b 100644
--- a/ui/messages/message.go
+++ b/ui/messages/message.go
@@ -30,7 +30,6 @@ type UIMessage interface {
Buffer() []tstring.TString
Height() int
- SenderID() string
RealSender() string
RegisterMatrix(matrix ifc.MatrixContainer)
}
diff --git a/ui/messages/meta.go b/ui/messages/meta.go
index 3a1dd19..23a52e9 100644
--- a/ui/messages/meta.go
+++ b/ui/messages/meta.go
@@ -34,6 +34,10 @@ func (meta *BasicMeta) Sender() string {
return meta.BSender
}
+func (meta *BasicMeta) SenderID() string {
+ return meta.BSender
+}
+
// SenderColor returns the color the name of the sender should be shown in.
func (meta *BasicMeta) SenderColor() tcell.Color {
return meta.BSenderColor
diff --git a/ui/view-main.go b/ui/view-main.go
index 9f7c690..c8977d3 100644
--- a/ui/view-main.go
+++ b/ui/view-main.go
@@ -429,6 +429,10 @@ func sendNotification(room *rooms.Room, sender, text string, critical, sound boo
}
func (view *MainView) NotifyMessage(room *rooms.Room, message ifc.Message, should pushrules.PushActionArrayShould) {
+ view.roomList.Bump(room)
+ if message.SenderID() == view.config.Session.UserID {
+ return
+ }
// 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.
@@ -436,7 +440,7 @@ func (view *MainView) NotifyMessage(room *rooms.Room, message ifc.Message, shoul
isFocused := time.Now().Add(-5 * 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
+ shouldNotify := should.Notify || !should.NotifySpecified
if !isCurrent || !isFocused {
// The message is not in the current room, show new message status in room list.
@@ -452,7 +456,6 @@ func (view *MainView) NotifyMessage(room *rooms.Room, message ifc.Message, shoul
}
message.SetIsHighlight(should.Highlight)
- view.roomList.Bump(room)
}
func (view *MainView) InitialSyncDone() {