From 11f6cb9d0e1b54a1567faebe99976c41ff42972d Mon Sep 17 00:00:00 2001 From: FIGBERT Date: Mon, 18 Sep 2023 00:47:38 -0700 Subject: [PATCH] Revert "Attempt new headless sync implementation" This reverts commit 05ccf81e574c9c54f4b8188a6a5cc2f097c9879f. --- headless/headless.go | 29 +++++++++++++++++++---------- matrix/matrix.go | 6 +----- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/headless/headless.go b/headless/headless.go index 2c75bfb..f3578ef 100644 --- a/headless/headless.go +++ b/headless/headless.go @@ -1,6 +1,7 @@ package headless import ( + "context" "errors" "fmt" "os" @@ -67,17 +68,25 @@ func Init(conf Config, updates chan fmt.Stringer) error { // sync updates <- beginningSync{} + resp, err := gmx.Matrix().Client().FullSyncRequest(mautrix.ReqSync{ + Timeout: 30000, + Since: "", + FilterID: "", + FullState: true, + SetPresence: gmx.Matrix().Client().SyncPresence, + Context: context.Background(), + StreamResponse: true, + }) + if err != nil { + return err + } + updates <- fetchedSyncData{} + gmx.Matrix().(*matrix.Container).InitSyncer() -syncloop: - for { - select { - case <-gmx.Matrix().(*matrix.Container).StopChannel(): - break syncloop - default: - if err := gmx.Matrix().Client().Sync(); err != nil { - return err - } - } + updates <- processingSync{} + err = gmx.Matrix().(*matrix.Container).ProcessSyncResponse(resp, "") + if err != nil { + return err } updates <- syncFinished{} diff --git a/matrix/matrix.go b/matrix/matrix.go index 6b9f82c..101114a 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -350,10 +350,6 @@ func (c *Container) Logout() { c.ui.OnLogout() } -func (c *Container) StopChannel() chan bool { - return c.stop -} - // Stop stops the Matrix syncer. func (c *Container) Stop() { if c.running { @@ -473,7 +469,7 @@ func (c *Container) InitSyncer() { } if c.headless { c.syncer.FirstDoneCallback = func() { - c.stop <- true + c.Stop() } }