mirror of
https://github.com/status-im/status-keycard-go.git
synced 2025-01-18 18:31:56 +00:00
only send insert card error if not found in 150ms
This commit is contained in:
parent
33e7ae0fe0
commit
c8b38fe24a
10
flow.go
10
flow.go
@ -2,6 +2,7 @@ package statuskeycardgo
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/status-im/status-keycard-go/signal"
|
||||
)
|
||||
@ -186,7 +187,9 @@ func (f *KeycardFlow) connect() (*keycardContext, error) {
|
||||
return nil, errors.New(ErrorConnection)
|
||||
}
|
||||
|
||||
f.pause(InsertCard, ErrorConnection, FlowParams{})
|
||||
t := time.NewTimer(150 * time.Millisecond)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-f.wakeUp:
|
||||
if f.state != Cancelling {
|
||||
@ -197,10 +200,13 @@ func (f *KeycardFlow) connect() (*keycardContext, error) {
|
||||
if kc.runErr != nil {
|
||||
return nil, restartErr()
|
||||
}
|
||||
|
||||
t.Stop()
|
||||
f.state = Running
|
||||
signal.Send(CardInserted, FlowStatus{})
|
||||
return kc, nil
|
||||
case <-t.C:
|
||||
f.pause(InsertCard, ErrorConnection, FlowParams{})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user