Skip to content

Commit

Permalink
Revert "Attempt new headless sync implementation"
Browse files Browse the repository at this point in the history
This reverts commit 05ccf81.
  • Loading branch information
FIGBERT committed Sep 18, 2023
1 parent 05ccf81 commit 11f6cb9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
29 changes: 19 additions & 10 deletions headless/headless.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package headless

import (
"context"
"errors"
"fmt"
"os"
Expand Down Expand Up @@ -67,17 +68,25 @@ func Init(conf Config, updates chan fmt.Stringer) error {

// 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{}

gmx.Matrix().(*matrix.Container).InitSyncer()
syncloop:
for {
select {
case <-gmx.Matrix().(*matrix.Container).StopChannel():
break syncloop
default:
if err := gmx.Matrix().Client().Sync(); err != nil {
return err
}
}
updates <- processingSync{}
err = gmx.Matrix().(*matrix.Container).ProcessSyncResponse(resp, "")
if err != nil {
return err
}
updates <- syncFinished{}

Expand Down
6 changes: 1 addition & 5 deletions matrix/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,6 @@ func (c *Container) Logout() {
c.ui.OnLogout()
}

func (c *Container) StopChannel() chan bool {
return c.stop
}

// Stop stops the Matrix syncer.
func (c *Container) Stop() {
if c.running {
Expand Down Expand Up @@ -473,7 +469,7 @@ func (c *Container) InitSyncer() {
}
if c.headless {
c.syncer.FirstDoneCallback = func() {
c.stop <- true
c.Stop()
}
}

Expand Down

0 comments on commit 11f6cb9

Please sign in to comment.