mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-19 18:13:41 -05:00
parent
ad1fd015cb
commit
58b212913c
3 changed files with 33 additions and 11 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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{}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue