Add hacky sleep before sending set active session request
This commit is contained in:
parent
eccbb9910e
commit
0f4f00295c
2 changed files with 9 additions and 0 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
@ -74,6 +75,8 @@ type Client struct {
|
|||
|
||||
conversationsFetchedOnce bool
|
||||
|
||||
hackyDelaySetActive atomic.Bool
|
||||
|
||||
AuthData *AuthData
|
||||
cfg *gmproto.Config
|
||||
|
||||
|
@ -160,6 +163,11 @@ func (c *Client) Connect() error {
|
|||
}
|
||||
|
||||
func (c *Client) postConnect() {
|
||||
// For some reason SetActiveSession fails if it's called immediately after reconnecting after a google login,
|
||||
// so hackily delay it a few seconds to make it work.
|
||||
if c.hackyDelaySetActive.CompareAndSwap(true, false) {
|
||||
time.Sleep(3 * time.Second)
|
||||
}
|
||||
c.Logger.Debug().Msg("Sending get updates request")
|
||||
err := c.SetActiveSession()
|
||||
if err != nil {
|
||||
|
|
|
@ -300,6 +300,7 @@ func (c *Client) DoGaiaPairing(ctx context.Context, emojiCallback func(string))
|
|||
c.AuthData.PairingID = ps.UUID
|
||||
c.triggerEvent(&events.PairSuccessful{PhoneID: c.AuthData.Mobile.GetSourceID()})
|
||||
|
||||
c.hackyDelaySetActive.Store(true)
|
||||
go func() {
|
||||
// Sleep for a bit to let the phone save the pair data. If we reconnect too quickly,
|
||||
// the phone won't recognize the session the bridge will get unpaired.
|
||||
|
|
Loading…
Reference in a new issue