From 58b212913ca464de80a499431f4fabe85a5291ac Mon Sep 17 00:00:00 2001 From: FIGBERT Date: Fri, 25 Aug 2023 13:19:02 -0700 Subject: [PATCH] Revert sync changes This reverts commits: 948bf767bcc9624fc21623c12c390f8a74431631 8fcbdddc62cf51c5e262758a851b26243f2ea6e2 --- headless/headless.go | 21 ++++++++++++++++++--- headless/msg.go | 18 ++++++++++++------ matrix/matrix.go | 5 +++-- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/headless/headless.go b/headless/headless.go index b02a212..f3578ef 100644 --- a/headless/headless.go +++ b/headless/headless.go @@ -1,6 +1,7 @@ package headless import ( + "context" "errors" "fmt" "os" @@ -66,10 +67,24 @@ func Init(conf Config, updates chan fmt.Stringer) error { updates <- configuredDisplayMode{} // sync - updates <- creatingSyncer{} + 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() - updates <- synchronizing{} - err = gmx.Matrix().Client().Sync() + updates <- processingSync{} + err = gmx.Matrix().(*matrix.Container).ProcessSyncResponse(resp, "") if err != nil { return err } diff --git a/headless/msg.go b/headless/msg.go index 67cb9c7..920ccab 100644 --- a/headless/msg.go +++ b/headless/msg.go @@ -32,16 +32,22 @@ func (msg configuredDisplayMode) String() string { return "Configured display mode…" } -type creatingSyncer struct{} +type beginningSync struct{} -func (msg creatingSyncer) String() string { - return "Initializing sync utilities…" +func (msg beginningSync) String() string { + return "Beginning the sync process…" } -type synchronizing struct{} +type fetchedSyncData struct{} -func (msg synchronizing) String() string { - return "Synchronizing…" +func (msg fetchedSyncData) String() string { + return "Fetched sync data…" +} + +type processingSync struct{} + +func (msg processingSync) String() string { + return "Processing sync response…" } type syncFinished struct{} diff --git a/matrix/matrix.go b/matrix/matrix.go index 2efd7ff..ab8f855 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -464,8 +464,9 @@ func (c *Container) InitSyncer() { debug.Print("Running GC") runtime.GC() dbg.FreeOSMemory() - - if c.headless { + } + if c.headless { + c.syncer.FirstDoneCallback = func() { c.Stop() } }