aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interface/ui.go1
-rw-r--r--matrix/matrix.go13
-rw-r--r--ui/view-main.go6
3 files changed, 18 insertions, 2 deletions
diff --git a/interface/ui.go b/interface/ui.go
index 48a6007..ad2458a 100644
--- a/interface/ui.go
+++ b/interface/ui.go
@@ -44,6 +44,7 @@ type MainView interface {
AddRoom(room *rooms.Room)
RemoveRoom(room *rooms.Room)
SetRooms(rooms *rooms.RoomCache)
+ Bump(room *rooms.Room)
UpdateTags(room *rooms.Room)
diff --git a/matrix/matrix.go b/matrix/matrix.go
index 8c19b24..1a75f96 100644
--- a/matrix/matrix.go
+++ b/matrix/matrix.go
@@ -315,7 +315,7 @@ func (c *Container) HandleMessage(source EventSource, evt *mautrix.Event) {
debug.Printf("Failed to add event %s to history: %v", evt.ID, err)
}
- if !c.config.AuthCache.InitialSyncDone || !room.Loaded() {
+ if !c.config.AuthCache.InitialSyncDone {
room.LastReceivedMessage = time.Unix(evt.Timestamp/1000, evt.Timestamp%1000*1000)
return
}
@@ -328,6 +328,17 @@ func (c *Container) HandleMessage(source EventSource, evt *mautrix.Event) {
return
}
+ if !room.Loaded() {
+ pushRules := c.PushRules().GetActions(room, evt).Should()
+ shouldNotify := pushRules.Notify || !pushRules.NotifySpecified
+ if !shouldNotify {
+ room.LastReceivedMessage = time.Unix(evt.Timestamp/1000, evt.Timestamp%1000*1000)
+ room.AddUnread(evt.ID, shouldNotify, pushRules.Highlight)
+ mainView.Bump(room)
+ return
+ }
+ }
+
// TODO switch to roomView.AddEvent
message := roomView.ParseEvent(evt)
if message != nil {
diff --git a/ui/view-main.go b/ui/view-main.go
index 5d2e1f9..ea24644 100644
--- a/ui/view-main.go
+++ b/ui/view-main.go
@@ -387,8 +387,12 @@ func sendNotification(room *rooms.Room, sender, text string, critical, sound boo
notification.Send(sender, text, critical, sound)
}
-func (view *MainView) NotifyMessage(room *rooms.Room, message ifc.Message, should pushrules.PushActionArrayShould) {
+func (view *MainView) Bump(room *rooms.Room) {
view.roomList.Bump(room)
+}
+
+func (view *MainView) NotifyMessage(room *rooms.Room, message ifc.Message, should pushrules.PushActionArrayShould) {
+ view.Bump(room)
uiMsg, ok := message.(*messages.UIMessage)
if ok && uiMsg.SenderID == view.config.UserID {
return