forked from Mirrors/gomuks
Use more generic sync process in headless mode
This commit is contained in:
parent
634a3350d5
commit
948bf767bc
3 changed files with 14 additions and 30 deletions
|
@ -1,7 +1,6 @@
|
||||||
package headless
|
package headless
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
@ -69,24 +68,10 @@ func Init(conf Config, updates chan fmt.Stringer) error {
|
||||||
updates <- configuredDisplayMode{}
|
updates <- configuredDisplayMode{}
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
updates <- beginningSync{}
|
updates <- creatingSyncer{}
|
||||||
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()
|
gmx.Matrix().(*matrix.Container).InitSyncer()
|
||||||
updates <- processingSync{}
|
updates <- synchronizing{}
|
||||||
err = gmx.Matrix().(*matrix.Container).ProcessSyncResponse(resp, "")
|
err = gmx.Matrix().Client().Sync()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,22 +32,16 @@ func (msg configuredDisplayMode) String() string {
|
||||||
return "Configured display mode…"
|
return "Configured display mode…"
|
||||||
}
|
}
|
||||||
|
|
||||||
type beginningSync struct{}
|
type creatingSyncer struct{}
|
||||||
|
|
||||||
func (msg beginningSync) String() string {
|
func (msg creatingSyncer) String() string {
|
||||||
return "Beginning the sync process…"
|
return "Initializing sync utilities…"
|
||||||
}
|
}
|
||||||
|
|
||||||
type fetchedSyncData struct{}
|
type synchronizing struct{}
|
||||||
|
|
||||||
func (msg fetchedSyncData) String() string {
|
func (msg synchronizing) String() string {
|
||||||
return "Fetched sync data…"
|
return "Synchronizing…"
|
||||||
}
|
|
||||||
|
|
||||||
type processingSync struct{}
|
|
||||||
|
|
||||||
func (msg processingSync) String() string {
|
|
||||||
return "Processing sync response…"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type syncFinished struct{}
|
type syncFinished struct{}
|
||||||
|
|
|
@ -439,6 +439,11 @@ func (c *Container) InitSyncer() {
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
dbg.FreeOSMemory()
|
dbg.FreeOSMemory()
|
||||||
}
|
}
|
||||||
|
if c.headless {
|
||||||
|
c.syncer.FirstDoneCallback = func() {
|
||||||
|
c.Stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c.client.Syncer = c.syncer
|
c.client.Syncer = c.syncer
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue