Skip to content

Commit 3a0602c

Browse files
committed
handle multiple calls to frozen-keycard-popup
1 parent 614f721 commit 3a0602c

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/status_im/keycard/common.cljs

+15-13
Original file line numberDiff line numberDiff line change
@@ -362,22 +362,24 @@
362362
(clear-on-card-read)
363363
(hide-connection-sheet))))
364364

365+
(fx/defn blocked-or-frozen-keycard-popup
366+
[{:keys [db] :as cofx} card-status]
367+
(fx/merge
368+
cofx
369+
{:db (assoc-in db [:keycard :pin :status] card-status)}
370+
(hide-connection-sheet)
371+
; do not try to display the popover if it is already open or
372+
; we are in the login interface (which has a different handling)
373+
(when-not (or (:multiaccounts/login db) (:popover/popover db))
374+
(popover/show-popover {:view card-status}))))
375+
365376
(fx/defn blocked-keycard-popup
366-
[{:keys [db] :as cofx}]
367-
(fx/merge cofx
368-
{:db (-> db
369-
(assoc-in [:keycard :pin :status] :blocked-card)
370-
(assoc :popover/popover {:view :blocked-card}))}
371-
(hide-connection-sheet)))
377+
[cofx]
378+
(blocked-or-frozen-keycard-popup cofx :blocked-card))
372379

373380
(fx/defn frozen-keycard-popup
374-
[{:keys [db] :as cofx}]
375-
(if (:multiaccounts/login db)
376-
(fx/merge
377-
cofx
378-
{:db (assoc-in db [:keycard :pin :status] :frozen-card)}
379-
hide-connection-sheet)
380-
(popover/show-popover cofx {:view :frozen-card})))
381+
[cofx]
382+
(blocked-or-frozen-keycard-popup cofx :frozen-card))
381383

382384
(fx/defn on-get-keys-error
383385
{:events [:keycard.callback/on-get-keys-error]}

0 commit comments

Comments
 (0)