diff --git a/headless/headless.go b/headless/headless.go index 6aa172a..0b9a533 100644 --- a/headless/headless.go +++ b/headless/headless.go @@ -1,7 +1,6 @@ package headless import ( - "context" "errors" "fmt" "os" @@ -69,24 +68,10 @@ func Init(conf Config, updates chan fmt.Stringer) error { updates <- configuredDisplayMode{} // 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{} - + updates <- creatingSyncer{} gmx.Matrix().(*matrix.Container).InitSyncer() - updates <- processingSync{} - err = gmx.Matrix().(*matrix.Container).ProcessSyncResponse(resp, "") + updates <- synchronizing{} + err = gmx.Matrix().Client().Sync() if err != nil { return err } diff --git a/headless/msg.go b/headless/msg.go index 226725c..ccf8d22 100644 --- a/headless/msg.go +++ b/headless/msg.go @@ -32,22 +32,16 @@ func (msg configuredDisplayMode) String() string { return "Configured display mode…" } -type beginningSync struct{} +type creatingSyncer struct{} -func (msg beginningSync) String() string { - return "Beginning the sync process…" +func (msg creatingSyncer) String() string { + return "Initializing sync utilities…" } -type fetchedSyncData struct{} +type synchronizing struct{} -func (msg fetchedSyncData) String() string { - return "Fetched sync data…" -} - -type processingSync struct{} - -func (msg processingSync) String() string { - return "Processing sync response…" +func (msg synchronizing) String() string { + return "Synchronizing…" } type syncFinished struct{} diff --git a/matrix/matrix.go b/matrix/matrix.go index 39c2ea4..f61de93 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -439,6 +439,11 @@ func (c *Container) InitSyncer() { runtime.GC() dbg.FreeOSMemory() } + if c.headless { + c.syncer.FirstDoneCallback = func() { + c.Stop() + } + } c.client.Syncer = c.syncer }