Fix notifications about own messages
This commit is contained in:
parent
a8a4c72d14
commit
512ca88804
@ -117,4 +117,6 @@ type Message interface {
|
|||||||
|
|
||||||
SetState(state MessageState)
|
SetState(state MessageState)
|
||||||
State() MessageState
|
State() MessageState
|
||||||
|
|
||||||
|
SenderID() string
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ type UIMessage interface {
|
|||||||
Buffer() []tstring.TString
|
Buffer() []tstring.TString
|
||||||
Height() int
|
Height() int
|
||||||
|
|
||||||
SenderID() string
|
|
||||||
RealSender() string
|
RealSender() string
|
||||||
RegisterMatrix(matrix ifc.MatrixContainer)
|
RegisterMatrix(matrix ifc.MatrixContainer)
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,10 @@ func (meta *BasicMeta) Sender() string {
|
|||||||
return meta.BSender
|
return meta.BSender
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (meta *BasicMeta) SenderID() string {
|
||||||
|
return meta.BSender
|
||||||
|
}
|
||||||
|
|
||||||
// SenderColor returns the color the name of the sender should be shown in.
|
// SenderColor returns the color the name of the sender should be shown in.
|
||||||
func (meta *BasicMeta) SenderColor() tcell.Color {
|
func (meta *BasicMeta) SenderColor() tcell.Color {
|
||||||
return meta.BSenderColor
|
return meta.BSenderColor
|
||||||
|
@ -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) {
|
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.
|
// Whether or not the room where the message came is the currently shown room.
|
||||||
isCurrent := room == view.roomList.SelectedRoom()
|
isCurrent := room == view.roomList.SelectedRoom()
|
||||||
// Whether or not the terminal window is focused.
|
// 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)
|
isFocused := time.Now().Add(-5 * time.Second).Before(view.lastFocusTime)
|
||||||
|
|
||||||
// Whether or not the push rules say this message should be notified about.
|
// 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 {
|
if !isCurrent || !isFocused {
|
||||||
// The message is not in the current room, show new message status in room list.
|
// 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)
|
message.SetIsHighlight(should.Highlight)
|
||||||
view.roomList.Bump(room)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (view *MainView) InitialSyncDone() {
|
func (view *MainView) InitialSyncDone() {
|
||||||
|
Loading…
Reference in New Issue
Block a user