Fix/break/change things

This commit is contained in:
Tulir Asokan 2018-04-24 17:12:08 +03:00
parent e64df67ec3
commit 28c6527544
5 changed files with 12 additions and 13 deletions

View File

@ -52,10 +52,6 @@ func (config *Config) NewSession(mxid string) *Session {
} }
} }
func (s *Session) SetInitialSyncDone() {
s.InitialSyncDone = true
}
func (s *Session) GetUserID() string { func (s *Session) GetUserID() string {
return s.UserID return s.UserID
} }

View File

@ -175,6 +175,10 @@ func (c *Container) OnLogin() {
c.syncer.OnEventType("m.typing", c.HandleTyping) c.syncer.OnEventType("m.typing", c.HandleTyping)
c.syncer.OnEventType("m.push_rules", c.HandlePushRules) c.syncer.OnEventType("m.push_rules", c.HandlePushRules)
c.syncer.OnEventType("m.tag", c.HandleTag) c.syncer.OnEventType("m.tag", c.HandleTag)
c.syncer.InitDoneCallback = func() {
c.config.Session.InitialSyncDone = true
c.ui.Render()
}
c.client.Syncer = c.syncer c.client.Syncer = c.syncer
debug.Print("Setting existing rooms") debug.Print("Setting existing rooms")
@ -224,7 +228,6 @@ func (c *Container) HandleMessage(evt *gomatrix.Event) {
message := mainView.ParseEvent(roomView, evt) message := mainView.ParseEvent(roomView, evt)
if message != nil { if message != nil {
debug.Print("Adding message", message.ID(), c.syncer.FirstSyncDone, c.config.Session.InitialSyncDone)
roomView.AddMessage(message, ifc.AppendMessage) roomView.AddMessage(message, ifc.AppendMessage)
if c.syncer.FirstSyncDone { if c.syncer.FirstSyncDone {
pushRules := c.PushRules().GetActions(roomView.MxRoom(), evt).Should() pushRules := c.PushRules().GetActions(roomView.MxRoom(), evt).Should()
@ -307,7 +310,6 @@ func (c *Container) HandleMembership(evt *gomatrix.Event) {
message := mainView.ParseEvent(roomView, evt) message := mainView.ParseEvent(roomView, evt)
if message != nil { if message != nil {
debug.Print("Adding membership event", message.ID(), c.syncer.FirstSyncDone, c.config.Session.InitialSyncDone)
// TODO this shouldn't be necessary // TODO this shouldn't be necessary
//roomView.MxRoom().UpdateState(evt) //roomView.MxRoom().UpdateState(evt)
// TODO This should probably also be in a different place // TODO This should probably also be in a different place

View File

@ -155,7 +155,7 @@ func (room *Room) UpdateState(event *gomatrix.Event) {
stateKey = *event.StateKey stateKey = *event.StateKey
} }
if event.Type != "m.room.member" { if event.Type != "m.room.member" {
debug.Printf("[ROOM] Updating state %s#%s for %s", event.Type, stateKey, room.ID) debug.Printf("Updating state %s#%s for %s", event.Type, stateKey, room.ID)
} }
if event.StateKey == nil { if event.StateKey == nil {

View File

@ -28,7 +28,6 @@ import (
type SyncerSession interface { type SyncerSession interface {
GetRoom(id string) *rooms.Room GetRoom(id string) *rooms.Room
SetInitialSyncDone()
GetUserID() string GetUserID() string
} }
@ -36,9 +35,10 @@ type SyncerSession interface {
// replace parts of this default syncer (e.g. the ProcessResponse method). The default syncer uses the observer // replace parts of this default syncer (e.g. the ProcessResponse method). The default syncer uses the observer
// pattern to notify callers about incoming events. See GomuksSyncer.OnEventType for more information. // pattern to notify callers about incoming events. See GomuksSyncer.OnEventType for more information.
type GomuksSyncer struct { type GomuksSyncer struct {
Session SyncerSession Session SyncerSession
listeners map[string][]gomatrix.OnEventListener // event type to listeners array listeners map[string][]gomatrix.OnEventListener // event type to listeners array
FirstSyncDone bool FirstSyncDone bool
InitDoneCallback func()
} }
// NewGomuksSyncer returns an instantiated GomuksSyncer // NewGomuksSyncer returns an instantiated GomuksSyncer
@ -81,8 +81,8 @@ func (s *GomuksSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (er
} }
} }
if since == "" { if since == "" && s.InitDoneCallback != nil {
s.Session.SetInitialSyncDone() s.InitDoneCallback()
} }
s.FirstSyncDone = true s.FirstSyncDone = true

View File

@ -234,6 +234,7 @@ func (view *MessageView) replaceBuffer(original messages.UIMessage, new messages
if start == -1 { if start == -1 {
debug.Print("Called replaceBuffer() with message that was not in the buffer:", original.ID()) debug.Print("Called replaceBuffer() with message that was not in the buffer:", original.ID())
debug.PrintStack()
view.appendBuffer(new) view.appendBuffer(new)
return return
} }