handlers to store and remove a set of currently confirming payouts

fix remove confirming-payout dispatch and call it from confirm payout callback

make sure confirming flag is set on db via handler

clean up logic for confirm button

assoc confirming? flag in local storage, update :payout-confirm-failed to actually produce an effect

update handler to reg-event-fx
This commit is contained in:
Rob Culliton 2018-05-24 11:19:41 -04:00
parent 08faa879df
commit b9c948b778
No known key found for this signature in database
GPG Key ID: 12802B6CC52A98B8
2 changed files with 30 additions and 22 deletions

View File

@ -425,6 +425,14 @@
(defn strip-0x [x]
(str/replace x #"^0x" ""))
(reg-event-fx
:set-confirming-payout
[interceptors (inject-cofx :store)]
(fn [{:keys [db store]} [_ issue-id]]
{:db (assoc-in db [:owner-bounties issue-id :confirming?] true)
:store (assoc-in store [:owner-bounties issue-id :confirming?] true)}))
(defn set-pending-revocation [location issue-id confirming-account]
(assoc-in location [::db/pending-revocations issue-id]
{:confirming-account confirming-account}))
@ -503,9 +511,9 @@
:data data}]
(println "data:" data)
(try
(dispatch [:set-confirming-payout issue-id])
(web3-eth/send-transaction! w3 payload
(send-transaction-callback issue-id pending-revocations))
{:db (assoc-in db [:owner-bounties issue-id :confirming?] true)}
(catch js/Error e
{:db (assoc-in db [:owner-bounties issue-id :confirm-failed?] true)
:dispatch-n [[:payout-confirm-failed issue-id e]
@ -515,20 +523,23 @@
(reg-event-fx
:payout-confirmed
interceptors
[interceptors [(inject-cofx :store)]]
(fn [{:keys [db]} [_ issue-id]]
{:dispatch [:load-owner-bounties]
:db (-> db
(dissoc-in [:owner-bounties issue-id :confirming?])
(assoc-in [:owner-bounties issue-id :confirmed?] true))}))
(assoc-in [:owner-bounties issue-id :confirmed?] true))
:store (dissoc-in store [:owner-bounties issue-id :confirming?])}))
(reg-event-db
(reg-event-fx
:payout-confirm-failed
(fn [db [_ issue-id e]]
[(inject-cofx :store)]
(fn [{:keys [db store]} [_ issue-id e]]
(println "payout-confirm-failed" issue-id e)
(-> db
(dissoc-in [:owner-bounties issue-id :confirming?])
(assoc-in [:owner-bounties issue-id :confirm-failed?] true))))
{:db (-> db
(dissoc-in [:owner-bounties issue-id :confirming?])
(assoc-in [:owner-bounties issue-id :confirm-failed?] true))
:store (dissoc-in store [:owner-bounties issue-id :confirming?])}))
(reg-event-fx

View File

@ -52,21 +52,18 @@
(common/human-time updated)]]]]])
(defn confirm-button [bounty claim]
(let [paid? (bnt/paid? claim)
merged? (bnt/merged? claim)]
(when (and merged? (not paid?))
(let [paid? (bnt/paid? claim)
merged? (bnt/merged? claim)
confirming? (bnt/confirming? bounty)
bot-unmined? (bnt/bot-confirm-unmined? bounty)]
(when (and merged?
(:payout_address bounty)
(not paid?)
(not confirming?)
(not bot-unmined?))
[primary-button-button
(merge {:on-click #(rf/dispatch [:confirm-payout claim])}
(if (and merged? (not paid?) (:payout_address bounty))
{}
{:disabled true})
(when (and (or (bnt/confirming? bounty)
(bnt/bot-confirm-unmined? bounty))
merged?)
{:class "busy loading" :disabled true}))
(if paid?
"Signed off"
"Confirm Payment")])))
{:on-click #(rf/dispatch [:confirm-payout claim])}
"Confirm Payment"])))