bug #4180 and revert #4038 - amount number formatting in wallet send

Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
Goran Jovic 2018-05-10 12:35:35 +03:00 committed by Julien Eluard
parent 6194bbde84
commit 8a355b1e75
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
2 changed files with 10 additions and 7 deletions

View File

@ -28,8 +28,7 @@
;; TODO(jeluard) both send and request flows should be merged
(views/letsubs [{:keys [to to-name whisper-identity]} [:wallet.send/transaction]
{:keys [amount amount-error]} [:wallet.request/transaction]
scroll (atom nil)
amount-text-value (atom nil)]
scroll (atom nil)]
[comp/simple-screen {:avoid-keyboard? true}
[comp/toolbar (i18n/label :t/new-request)]
[react/view components.styles/flex
@ -46,8 +45,7 @@
:input-options {:default-value (str (money/to-fixed (money/wei->ether amount)))
:max-length 21
:on-focus (fn [] (when @scroll (utils/set-timeout #(.scrollToEnd @scroll) 100)))
:on-change-text #(reset! amount-text-value %)
:on-end-editing #(re-frame/dispatch [:wallet.request/set-and-validate-amount @amount-text-value])}}]]]
:on-change-text #(re-frame/dispatch [:wallet.request/set-and-validate-amount %])}}]]]
[bottom-buttons/bottom-buttons styles/bottom-buttons
nil ;; Force a phantom button to ensure consistency with other transaction screens which define 2 buttons
[button/button {:disabled? (not (and to amount))

View File

@ -194,9 +194,15 @@
(when advanced?
[advanced-cartouche transaction modal?])])
(defn update-amount-fn [timeout]
(fn [amount]
(when @timeout
(utils/clear-timeout @timeout))
(reset! timeout (utils/set-timeout #(re-frame/dispatch [:wallet.send/set-and-validate-amount amount]) 500))))
(defn- send-transaction-panel [{:keys [modal? transaction scroll advanced? symbol]}]
(let [{:keys [amount amount-error signing? to to-name sufficient-funds? in-progress? from-chat?]} transaction
amount-text-value (atom nil)]
timeout (atom nil)]
[wallet.components/simple-screen {:avoid-keyboard? (not modal?)
:status-bar-type (if modal? :modal-wallet :wallet)}
[toolbar from-chat? (if modal? act/close-white act/back-white)
@ -221,8 +227,7 @@
:input-options {:default-value (str (money/to-fixed (money/wei->ether amount)))
:max-length 21
:on-focus (fn [] (when (and scroll @scroll) (utils/set-timeout #(.scrollToEnd @scroll) 100)))
:on-change-text #(reset! amount-text-value %)
:on-end-editing #(re-frame/dispatch [:wallet.send/set-and-validate-amount @amount-text-value])}}]
:on-change-text (update-amount-fn timeout)}}]
[advanced-options advanced? transaction modal?]]]
(if signing?
[signing-buttons