forked from Mirrors/gomuks
Attempt new headless sync implementation
This commit is contained in:
parent
c3920a41b6
commit
05ccf81e57
2 changed files with 15 additions and 20 deletions
|
@ -1,7 +1,6 @@
|
||||||
package headless
|
package headless
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
@ -68,25 +67,17 @@ func Init(conf Config, updates chan fmt.Stringer) error {
|
||||||
|
|
||||||
// sync
|
// sync
|
||||||
updates <- beginningSync{}
|
updates <- beginningSync{}
|
||||||
resp, err := gmx.Matrix().Client().FullSyncRequest(mautrix.ReqSync{
|
gmx.Matrix().(*matrix.Container).InitSyncer()
|
||||||
Timeout: 30000,
|
syncloop:
|
||||||
Since: "",
|
for {
|
||||||
FilterID: "",
|
select {
|
||||||
FullState: true,
|
case <-gmx.Matrix().(*matrix.Container).StopChannel():
|
||||||
SetPresence: gmx.Matrix().Client().SyncPresence,
|
break syncloop
|
||||||
Context: context.Background(),
|
default:
|
||||||
StreamResponse: true,
|
if err := gmx.Matrix().Client().Sync(); err != nil {
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
updates <- fetchedSyncData{}
|
}
|
||||||
|
|
||||||
gmx.Matrix().(*matrix.Container).InitSyncer()
|
|
||||||
updates <- processingSync{}
|
|
||||||
err = gmx.Matrix().(*matrix.Container).ProcessSyncResponse(resp, "")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
updates <- syncFinished{}
|
updates <- syncFinished{}
|
||||||
|
|
||||||
|
|
|
@ -350,6 +350,10 @@ func (c *Container) Logout() {
|
||||||
c.ui.OnLogout()
|
c.ui.OnLogout()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Container) StopChannel() chan bool {
|
||||||
|
return c.stop
|
||||||
|
}
|
||||||
|
|
||||||
// Stop stops the Matrix syncer.
|
// Stop stops the Matrix syncer.
|
||||||
func (c *Container) Stop() {
|
func (c *Container) Stop() {
|
||||||
if c.running {
|
if c.running {
|
||||||
|
@ -469,7 +473,7 @@ func (c *Container) InitSyncer() {
|
||||||
}
|
}
|
||||||
if c.headless {
|
if c.headless {
|
||||||
c.syncer.FirstDoneCallback = func() {
|
c.syncer.FirstDoneCallback = func() {
|
||||||
c.Stop()
|
c.stop <- true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue