1
0
Fork 0
forked from Mirrors/gomuks

Use more generic sync process in headless mode

This commit is contained in:
FIGBERT 2023-08-17 10:30:18 -07:00
parent 634a3350d5
commit 948bf767bc
No known key found for this signature in database
GPG key ID: 67F1598D607A844B
3 changed files with 14 additions and 30 deletions

View file

@ -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
}

View file

@ -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{}

View file

@ -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
}