aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-05-15 18:45:09 +0300
committerTulir Asokan <tulir@maunium.net>2018-05-15 18:47:34 +0300
commitcb3a6e764e3bd9023986bbce22ea971e7aa0a9d9 (patch)
treecedc6aadaec21ba4ddd0d5d1d0d1a66e9acbc7dd
parentfdbb168e2bd4ba6eca864a41c0d1906669fb5fbe (diff)
Fix room ordering after initial sync (ref #36)
-rw-r--r--interface/ui.go1
-rw-r--r--matrix/matrix.go3
-rw-r--r--ui/view-main.go8
3 files changed, 11 insertions, 1 deletions
diff --git a/interface/ui.go b/interface/ui.go
index e487d3e..b69f048 100644
--- a/interface/ui.go
+++ b/interface/ui.go
@@ -52,6 +52,7 @@ type MainView interface {
ParseEvent(roomView RoomView, evt *gomatrix.Event) Message
NotifyMessage(room *rooms.Room, message Message, should pushrules.PushActionArrayShould)
+ InitialSyncDone()
}
type MessageDirection int
diff --git a/matrix/matrix.go b/matrix/matrix.go
index 7bb790e..7fbef5f 100644
--- a/matrix/matrix.go
+++ b/matrix/matrix.go
@@ -182,6 +182,7 @@ func (c *Container) OnLogin() {
c.syncer.OnEventType("m.tag", c.HandleTag)
c.syncer.InitDoneCallback = func() {
c.config.Session.InitialSyncDone = true
+ c.ui.MainView().InitialSyncDone()
c.ui.Render()
}
c.client.Syncer = c.syncer
@@ -241,6 +242,7 @@ func (c *Container) HandleMessage(source EventSource, evt *gomatrix.Event) {
message := mainView.ParseEvent(roomView, evt)
if message != nil {
roomView.AddMessage(message, ifc.AppendMessage)
+ roomView.MxRoom().LastReceivedMessage = message.Timestamp()
if c.syncer.FirstSyncDone {
pushRules := c.PushRules().GetActions(roomView.MxRoom(), evt).Should()
mainView.NotifyMessage(roomView.MxRoom(), message, pushRules)
@@ -333,6 +335,7 @@ func (c *Container) HandleMembership(source EventSource, evt *gomatrix.Event) {
message := mainView.ParseEvent(roomView, evt)
if message != nil {
roomView.AddMessage(message, ifc.AppendMessage)
+ roomView.MxRoom().LastReceivedMessage = message.Timestamp()
// We don't want notifications at startup.
if c.syncer.FirstSyncDone {
pushRules := c.PushRules().GetActions(roomView.MxRoom(), evt).Should()
diff --git a/ui/view-main.go b/ui/view-main.go
index c8b24f1..beb6f5f 100644
--- a/ui/view-main.go
+++ b/ui/view-main.go
@@ -470,10 +470,16 @@ func (view *MainView) NotifyMessage(room *rooms.Room, message ifc.Message, shoul
}
message.SetIsHighlight(should.Highlight)
- room.LastReceivedMessage = message.Timestamp()
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) {
defer debug.Recover()
roomView := view.rooms[room]