From fcd9a932cb5542ed8980fc1daba7ee1f0041a3f2 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 24 Apr 2018 02:11:32 +0300 Subject: Initial move to initial sync. Everything broke :( --- matrix/matrix.go | 6 +++++- matrix/sync.go | 18 ++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'matrix') diff --git a/matrix/matrix.go b/matrix/matrix.go index d58ce20..5345c40 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -191,7 +191,7 @@ func (c *Container) OnLogin() { c.syncer.OnEventType("m.tag", c.HandleTag) c.client.Syncer = c.syncer - c.UpdateRoomList() + //c.UpdateRoomList() } // Start moves the UI to the main view, calls OnLogin() and runs the syncer forever until stopped with Stop() @@ -296,6 +296,10 @@ func (c *Container) HandleMembership(evt *gomatrix.Event) { c.processOwnMembershipChange(evt) } + if !c.config.Session.InitialSyncDone && evt.Timestamp < time.Now().Add(-1*time.Hour).Unix() { + return + } + mainView := c.ui.MainView() roomView := mainView.GetRoom(evt.RoomID) if roomView == nil { diff --git a/matrix/sync.go b/matrix/sync.go index f3966cb..ec1c34e 100644 --- a/matrix/sync.go +++ b/matrix/sync.go @@ -20,16 +20,16 @@ package matrix import ( "encoding/json" - "fmt" - "runtime/debug" "time" "maunium.net/go/gomatrix" + "maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/matrix/rooms" ) type SyncerSession interface { GetRoom(id string) *rooms.Room + SetInitialSyncDone() GetUserID() string } @@ -53,16 +53,7 @@ func NewGomuksSyncer(session SyncerSession) *GomuksSyncer { // ProcessResponse processes a Matrix sync response. func (s *GomuksSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (err error) { - if len(since) == 0 { - return - } - // debug.Print("Processing sync response", since, res) - - defer func() { - if r := recover(); r != nil { - err = fmt.Errorf("ProcessResponse for %s since %s panicked: %s\n%s", s.Session.GetUserID(), since, r, debug.Stack()) - } - }() + debug.Print("Processing sync response", since, res) s.processSyncEvents(nil, res.Presence.Events, false, false) s.processSyncEvents(nil, res.AccountData.Events, false, false) @@ -93,6 +84,9 @@ func (s *GomuksSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (er } } + if since == "" { + s.Session.SetInitialSyncDone() + } s.FirstSyncDone = true return -- cgit v1.2.3