Fix room ordering after initial sync (ref #36)
This commit is contained in:
parent
fdbb168e2b
commit
cb3a6e764e
@ -52,6 +52,7 @@ type MainView interface {
|
|||||||
ParseEvent(roomView RoomView, evt *gomatrix.Event) Message
|
ParseEvent(roomView RoomView, evt *gomatrix.Event) Message
|
||||||
|
|
||||||
NotifyMessage(room *rooms.Room, message Message, should pushrules.PushActionArrayShould)
|
NotifyMessage(room *rooms.Room, message Message, should pushrules.PushActionArrayShould)
|
||||||
|
InitialSyncDone()
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageDirection int
|
type MessageDirection int
|
||||||
|
@ -182,6 +182,7 @@ func (c *Container) OnLogin() {
|
|||||||
c.syncer.OnEventType("m.tag", c.HandleTag)
|
c.syncer.OnEventType("m.tag", c.HandleTag)
|
||||||
c.syncer.InitDoneCallback = func() {
|
c.syncer.InitDoneCallback = func() {
|
||||||
c.config.Session.InitialSyncDone = true
|
c.config.Session.InitialSyncDone = true
|
||||||
|
c.ui.MainView().InitialSyncDone()
|
||||||
c.ui.Render()
|
c.ui.Render()
|
||||||
}
|
}
|
||||||
c.client.Syncer = c.syncer
|
c.client.Syncer = c.syncer
|
||||||
@ -241,6 +242,7 @@ func (c *Container) HandleMessage(source EventSource, evt *gomatrix.Event) {
|
|||||||
message := mainView.ParseEvent(roomView, evt)
|
message := mainView.ParseEvent(roomView, evt)
|
||||||
if message != nil {
|
if message != nil {
|
||||||
roomView.AddMessage(message, ifc.AppendMessage)
|
roomView.AddMessage(message, ifc.AppendMessage)
|
||||||
|
roomView.MxRoom().LastReceivedMessage = message.Timestamp()
|
||||||
if c.syncer.FirstSyncDone {
|
if c.syncer.FirstSyncDone {
|
||||||
pushRules := c.PushRules().GetActions(roomView.MxRoom(), evt).Should()
|
pushRules := c.PushRules().GetActions(roomView.MxRoom(), evt).Should()
|
||||||
mainView.NotifyMessage(roomView.MxRoom(), message, pushRules)
|
mainView.NotifyMessage(roomView.MxRoom(), message, pushRules)
|
||||||
@ -333,6 +335,7 @@ func (c *Container) HandleMembership(source EventSource, evt *gomatrix.Event) {
|
|||||||
message := mainView.ParseEvent(roomView, evt)
|
message := mainView.ParseEvent(roomView, evt)
|
||||||
if message != nil {
|
if message != nil {
|
||||||
roomView.AddMessage(message, ifc.AppendMessage)
|
roomView.AddMessage(message, ifc.AppendMessage)
|
||||||
|
roomView.MxRoom().LastReceivedMessage = message.Timestamp()
|
||||||
// We don't want notifications at startup.
|
// We don't want notifications at startup.
|
||||||
if c.syncer.FirstSyncDone {
|
if c.syncer.FirstSyncDone {
|
||||||
pushRules := c.PushRules().GetActions(roomView.MxRoom(), evt).Should()
|
pushRules := c.PushRules().GetActions(roomView.MxRoom(), evt).Should()
|
||||||
|
@ -470,10 +470,16 @@ func (view *MainView) NotifyMessage(room *rooms.Room, message ifc.Message, shoul
|
|||||||
}
|
}
|
||||||
|
|
||||||
message.SetIsHighlight(should.Highlight)
|
message.SetIsHighlight(should.Highlight)
|
||||||
room.LastReceivedMessage = message.Timestamp()
|
|
||||||
view.roomList.Bump(room)
|
view.roomList.Bump(room)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (view *MainView) InitialSyncDone() {
|
||||||
|
view.roomList.Clear()
|
||||||
|
for _, room := range view.rooms {
|
||||||
|
view.roomList.Add(room.Room)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (view *MainView) LoadHistory(room string) {
|
func (view *MainView) LoadHistory(room string) {
|
||||||
defer debug.Recover()
|
defer debug.Recover()
|
||||||
roomView := view.rooms[room]
|
roomView := view.rooms[room]
|
||||||
|
Loading…
Reference in New Issue
Block a user