refactor(qr): move ticker to local scope

This commit is contained in:
ayn2op 2025-12-15 05:40:19 -05:00
parent bed98bec76
commit 67887cec22

View file

@ -200,13 +200,6 @@ func (q *qrLogin) run(ctx context.Context) {
}
}()
var heartbeatTicker *time.Ticker
defer func() {
if heartbeatTicker != nil {
heartbeatTicker.Stop()
}
}()
for {
select {
case <-ctx.Done():
@ -237,8 +230,9 @@ func (q *qrLogin) run(ctx context.Context) {
return
}
if h.HeartbeatInterval > 0 {
heartbeatTicker = time.NewTicker(time.Duration(h.HeartbeatInterval) * time.Millisecond)
heartbeatTicker := time.NewTicker(time.Duration(h.HeartbeatInterval) * time.Millisecond)
go func() {
defer heartbeatTicker.Stop()
for {
select {
case <-ctx.Done():