client: Wait before returning from disconnect
This commit is contained in:
@@ -47,6 +47,7 @@ type QRLogin struct {
|
||||
|
||||
authClientCtx context.Context
|
||||
authClientCancel context.CancelFunc
|
||||
authClientCloseC <-chan struct{}
|
||||
|
||||
auth chan qrAuthResult
|
||||
qrToken chan qrlogin.Token
|
||||
@@ -61,6 +62,9 @@ func (q *QRLogin) Cancel() {
|
||||
if q.authClientCancel != nil {
|
||||
q.authClientCancel()
|
||||
}
|
||||
if q.authClientCloseC != nil {
|
||||
<-q.authClientCloseC
|
||||
}
|
||||
}
|
||||
|
||||
func (q *QRLogin) Start(ctx context.Context) (*bridgev2.LoginStep, error) {
|
||||
@@ -85,7 +89,7 @@ func (q *QRLogin) Start(ctx context.Context) (*bridgev2.LoginStep, error) {
|
||||
|
||||
var err error
|
||||
q.authClientCtx, q.authClientCancel = context.WithTimeoutCause(log.WithContext(context.Background()), time.Hour, errors.New("phone login took over one hour"))
|
||||
if err = connectTelegramClient(q.authClientCtx, q.authClientCancel, q.authClient); err != nil {
|
||||
if q.authClientCloseC, err = connectTelegramClient(q.authClientCtx, q.authClientCancel, q.authClient); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user