193 review fixes
This commit is contained in:
parent
c2d6094dad
commit
4717a1a590
|
@ -226,25 +226,21 @@
|
|||
(POST "/" []
|
||||
:auth-rules authenticated?
|
||||
:current-user user
|
||||
:body [body {(s/optional-key :address) s/Str
|
||||
(s/optional-key :is_hidden_in_hunters) s/Bool}]
|
||||
:body [body {:address s/Str
|
||||
:is_hidden_in_hunters s/Bool}]
|
||||
:summary "Updates user's fields."
|
||||
|
||||
(let [user-id (:id user)
|
||||
fields (select-keys body [:address :is_hidden_in_hunters])]
|
||||
{:keys [address]} body]
|
||||
|
||||
(when (empty? fields)
|
||||
(bad-request! "No incoming fields were found."))
|
||||
|
||||
(when-let [address (:address fields)]
|
||||
(when-not (eth/valid-address? address)
|
||||
(log/debugf "POST /user: Wrong address %s" address)
|
||||
(bad-request! (format "Invalid Ethereum address: %s" address))))
|
||||
(when-not (eth/valid-address? address)
|
||||
(log/debugf "POST /user: Wrong address %s" address)
|
||||
(bad-request! (format "Invalid Ethereum address: %s" address)))
|
||||
|
||||
(db/with-tx
|
||||
(when-not (db/user-exists? {:id user-id})
|
||||
(not-found! "No such a user."))
|
||||
(db/update! :users fields ["id = ?" user-id]))
|
||||
(db/update! :users body ["id = ?" user-id]))
|
||||
|
||||
(ok)))
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
(let [db (rf/subscribe [:db])
|
||||
updating-user (rf/subscribe [:get-in [:updating-user]])
|
||||
address (r/atom @(rf/subscribe [:get-in [:user :address]]))
|
||||
is-hidden (rf/subscribe [:get-in [:user :is_hidden_in_hunters]])]
|
||||
hidden (r/atom @(rf/subscribe [:get-in [:user :is_hidden_in_hunters]]))]
|
||||
|
||||
(fn []
|
||||
(let [web3 (:web3 @db)
|
||||
|
@ -45,23 +45,27 @@
|
|||
:auto-correct "off"
|
||||
:spell-check "false"
|
||||
:max-length 42}]])]
|
||||
[:button
|
||||
(merge {:on-click
|
||||
#(rf/dispatch [:save-user-fields {:address @address}])
|
||||
:class (str "ui button small update-address-button"
|
||||
(when @updating-user
|
||||
" busy loading"))})
|
||||
"UPDATE"]
|
||||
|
||||
[:h3 "Settings"]
|
||||
[:div
|
||||
[:input
|
||||
{:type :checkbox
|
||||
:disabled @updating-user
|
||||
:id :input-hidden
|
||||
:checked @is-hidden
|
||||
:checked @hidden
|
||||
:on-change
|
||||
(fn [e]
|
||||
(let [value (-> e .-target .-checked)]
|
||||
(rf/dispatch [:save-user-fields {:is_hidden_in_hunters value}])))}]
|
||||
[:label {:for :input-hidden} "Disguise myself from the top hunters and activity lists."]]]]))))
|
||||
(reset! hidden value)))}]
|
||||
|
||||
[:label {:for :input-hidden} "Disguise myself from the top hunters and activity lists."]]
|
||||
|
||||
[:button
|
||||
(merge {:on-click
|
||||
#(rf/dispatch [:save-user-fields {:address @address
|
||||
:is_hidden_in_hunters @hidden}])
|
||||
:class (str "ui button small update-address-button"
|
||||
(when @updating-user
|
||||
" busy loading"))})
|
||||
"UPDATE"]
|
||||
|
||||
]]))))
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
.update-address-button {
|
||||
background-color: #57a7ed!important;
|
||||
margin-top: 10px !important;
|
||||
&:hover {
|
||||
background-color: #57a7ed!important;
|
||||
}
|
||||
|
@ -1291,5 +1292,3 @@ body {
|
|||
color: #8d99a4;
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue