Skip to content

Commit

Permalink
login: remove duplicate sync chats call
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Jan 19, 2025
1 parent bd09149 commit 1e622b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
10 changes: 0 additions & 10 deletions pkg/connector/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,6 @@ func (s *SignalClient) bridgeStateLoop(statusChan <-chan signalmeow.SignalConnec
}
}

func (s *SignalClient) postLoginConnect(ctx context.Context) {
// TODO it would be more proper to only connect after syncing,
// but currently syncing will fetch group info online, so it has to be connected.
s.Connect(ctx)
s.syncChats(ctx)
if s.Client.Store.MasterKey != nil {
s.Client.SyncStorage(ctx)
}
}

func (s *SignalClient) Connect(ctx context.Context) {
if s.Client == nil {
s.UserLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateBadCredentials, Message: "You're not logged into Signal"})
Expand Down
15 changes: 6 additions & 9 deletions pkg/connector/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,12 @@ func (qr *QRLogin) processingWait(ctx context.Context) (*bridgev2.LoginStep, err
}
backgroundCtx := ul.Log.WithContext(context.Background())
signalClient := ul.Client.(*SignalClient).Client
if signalClient.Store.EphemeralBackupKey != nil {
zerolog.Ctx(ctx).Info().Msg("Received ephemeral backup key in login, syncing chats before connecting")
go ul.Client.(*SignalClient).postLoginConnect(backgroundCtx)
} else {
ul.Client.Connect(backgroundCtx)
if signalClient.Store.MasterKey != nil {
zerolog.Ctx(ctx).Info().Msg("Received master key in login, syncing storage immediately")
go signalClient.SyncStorage(backgroundCtx)
}
// TODO it would be more proper to only connect after syncing,
// but currently syncing will fetch group info online, so it has to be connected.
ul.Client.Connect(backgroundCtx)
if signalClient.Store.MasterKey != nil {
zerolog.Ctx(ctx).Info().Msg("Received master key in login, syncing storage immediately")
go signalClient.SyncStorage(backgroundCtx)
}
return &bridgev2.LoginStep{
Type: bridgev2.LoginStepTypeComplete,
Expand Down

0 comments on commit 1e622b7

Please sign in to comment.