mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
parent
ad1fd015cb
commit
58b212913c
3 changed files with 33 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
||||||
package headless
|
package headless
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
@ -66,10 +67,24 @@ func Init(conf Config, updates chan fmt.Stringer) error {
|
||||||
updates <- configuredDisplayMode{}
|
updates <- configuredDisplayMode{}
|
||||||
|
|
||||||
// sync
|
// 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()
|
gmx.Matrix().(*matrix.Container).InitSyncer()
|
||||||
updates <- synchronizing{}
|
updates <- processingSync{}
|
||||||
err = gmx.Matrix().Client().Sync()
|
err = gmx.Matrix().(*matrix.Container).ProcessSyncResponse(resp, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,16 +32,22 @@ func (msg configuredDisplayMode) String() string {
|
||||||
return "Configured display mode…"
|
return "Configured display mode…"
|
||||||
}
|
}
|
||||||
|
|
||||||
type creatingSyncer struct{}
|
type beginningSync struct{}
|
||||||
|
|
||||||
func (msg creatingSyncer) String() string {
|
func (msg beginningSync) String() string {
|
||||||
return "Initializing sync utilities…"
|
return "Beginning the sync process…"
|
||||||
}
|
}
|
||||||
|
|
||||||
type synchronizing struct{}
|
type fetchedSyncData struct{}
|
||||||
|
|
||||||
func (msg synchronizing) String() string {
|
func (msg fetchedSyncData) String() string {
|
||||||
return "Synchronizing…"
|
return "Fetched sync data…"
|
||||||
|
}
|
||||||
|
|
||||||
|
type processingSync struct{}
|
||||||
|
|
||||||
|
func (msg processingSync) String() string {
|
||||||
|
return "Processing sync response…"
|
||||||
}
|
}
|
||||||
|
|
||||||
type syncFinished struct{}
|
type syncFinished struct{}
|
||||||
|
|
|
@ -464,8 +464,9 @@ func (c *Container) InitSyncer() {
|
||||||
debug.Print("Running GC")
|
debug.Print("Running GC")
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
dbg.FreeOSMemory()
|
dbg.FreeOSMemory()
|
||||||
|
}
|
||||||
if c.headless {
|
if c.headless {
|
||||||
|
c.syncer.FirstDoneCallback = func() {
|
||||||
c.Stop()
|
c.Stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue