handle multiple calls to frozen-keycard-popup

Signed-off-by: Churikova Tetiana <churikova.tm@gmail.com>
This commit is contained in:
Michele Balistreri 2021-08-23 13:25:54 +03:00 committed by Churikova Tetiana
parent 614f7211d2
commit e3f471ecf6
No known key found for this signature in database
GPG Key ID: 0D4EA7B33B47E6D8
1 changed files with 15 additions and 13 deletions

View File

@ -362,22 +362,24 @@
(clear-on-card-read)
(hide-connection-sheet))))
(fx/defn blocked-or-frozen-keycard-popup
[{:keys [db] :as cofx} card-status]
(fx/merge
cofx
{:db (assoc-in db [:keycard :pin :status] card-status)}
(hide-connection-sheet)
; do not try to display the popover if it is already open or
; we are in the login interface (which has a different handling)
(when-not (or (:multiaccounts/login db) (:popover/popover db))
(popover/show-popover {:view card-status}))))
(fx/defn blocked-keycard-popup
[{:keys [db] :as cofx}]
(fx/merge cofx
{:db (-> db
(assoc-in [:keycard :pin :status] :blocked-card)
(assoc :popover/popover {:view :blocked-card}))}
(hide-connection-sheet)))
[cofx]
(blocked-or-frozen-keycard-popup cofx :blocked-card))
(fx/defn frozen-keycard-popup
[{:keys [db] :as cofx}]
(if (:multiaccounts/login db)
(fx/merge
cofx
{:db (assoc-in db [:keycard :pin :status] :frozen-card)}
hide-connection-sheet)
(popover/show-popover cofx {:view :frozen-card})))
[cofx]
(blocked-or-frozen-keycard-popup cofx :frozen-card))
(fx/defn on-get-keys-error
{:events [:keycard.callback/on-get-keys-error]}