Fix bumping unloaded rooms in room list when receiving messages

This commit is contained in:
Tulir Asokan
2019-06-15 17:51:36 +03:00
parent 160b035c4d
commit 0f08c49df4
3 changed files with 18 additions and 2 deletions

View File

@ -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 {