mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 18:43:41 -05:00
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
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -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{}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue