Skip to content

Commit 7958f26

Browse files
authored
resets ledger ui status between errors (#5490)
* resets ledger ui status between errors removes the error status (e.g., 'Open Ledger App Ironfish') after the user has resolved the cause of the error * uses timer to clear status ledger ux action status sets a timer to clear the status instead of clearing on each iteration. prevents error status message from flashing if the user has not fixed the cause between iterations
1 parent df1f22c commit 7958f26

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

ironfish-cli/src/ui/ledger.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export async function ledger<TResult>({
4949
ux.action.start(message)
5050
}
5151

52+
let clearStatusTimer
53+
5254
try {
5355
// eslint-disable-next-line no-constant-condition
5456
while (true) {
@@ -57,6 +59,7 @@ export async function ledger<TResult>({
5759
ux.action.stop()
5860
return result
5961
} catch (e) {
62+
clearTimeout(clearStatusTimer)
6063
if (e instanceof LedgerAppLocked) {
6164
// If an app is running and it's locked, trying to poll the device
6265
// will cause the Ledger device to hide the pin screen as the user
@@ -101,13 +104,15 @@ export async function ledger<TResult>({
101104
}
102105

103106
statusAdded = true
107+
clearStatusTimer = setTimeout(() => (ux.action.status = undefined), 2000)
104108
await PromiseUtils.sleep(1000)
105109
continue
106110
}
107111
}
108112
} finally {
109113
// Don't interrupt an existing status outside of ledgerAction()
110114
if (!wasRunning && statusAdded) {
115+
clearTimeout(clearStatusTimer)
111116
ux.action.stop()
112117
}
113118
}

0 commit comments

Comments
 (0)