Crash when trying to add Waku settings in Advanced Settings #21155 (#21302)

This commit is contained in:
flexsurfer 2024-09-24 17:00:51 +02:00 committed by GitHub
parent 9258f2a513
commit b11d3bed78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 49 additions and 37 deletions

View File

@ -7,6 +7,7 @@
[legacy.status-im.ui.components.topbar :as topbar] [legacy.status-im.ui.components.topbar :as topbar]
[legacy.status-im.ui.screens.wakuv2-settings.edit-node.styles :as styles] [legacy.status-im.ui.screens.wakuv2-settings.edit-node.styles :as styles]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[react-native.safe-area :as safe-area]
[utils.i18n :as i18n]) [utils.i18n :as i18n])
(:require-macros [legacy.status-im.utils.views :as views])) (:require-macros [legacy.status-im.utils.views :as views]))
@ -33,39 +34,40 @@
[react/keyboard-avoiding-view [react/keyboard-avoiding-view
{:style {:flex 1} {:style {:flex 1}
:ignore-offset true} :ignore-offset true}
[topbar/topbar {:title (i18n/label (if name :t/node-details :t/add-node))}] [react/view {:flex 1 :padding-bottom (safe-area/get-bottom)}
[react/scroll-view {:keyboard-should-persist-taps :handled} [topbar/topbar {:title (i18n/label (if name :t/node-details :t/add-node))}]
[react/view styles/edit-node-view [react/scroll-view {:keyboard-should-persist-taps :handled}
[react/view {:padding-vertical 8} [react/view styles/edit-node-view
[quo/text-input [react/view {:padding-vertical 8}
{:label (i18n/label :t/name) [quo/text-input
:placeholder (i18n/label :t/specify-name) {:label (i18n/label :t/name)
:accessibility-label :node-name :placeholder (i18n/label :t/specify-name)
:default-value name :accessibility-label :node-name
:on-change-text #(re-frame/dispatch [:wakuv2.ui/input-changed :name %]) :default-value name
:auto-focus true}]] :on-change-text #(re-frame/dispatch [:wakuv2.ui/input-changed :name %])
[react/view :auto-focus true}]]
{:flex 1 [react/view
:padding-vertical 8} {:flex 1
[quo/text-input :padding-vertical 8}
(merge [quo/text-input
{:label (i18n/label :t/node-address) (merge
:placeholder (i18n/label :t/wakuv2-node-format) {:label (i18n/label :t/node-address)
:accessibility-label :node-address :placeholder (i18n/label :t/wakuv2-node-format)
:default-value address :accessibility-label :node-address
:show-cancel false :default-value address
:on-change-text #(re-frame/dispatch [:wakuv2.ui/input-changed :address %]) :show-cancel false
:error (when (and (not (string/blank? address)) invalid-address?) :on-change-text #(re-frame/dispatch [:wakuv2.ui/input-changed :address %])
(i18n/label :t/invalid-format :error (when (and (not (string/blank? address)) invalid-address?)
{:format (i18n/label :t/wakuv2-node-format)})) (i18n/label :t/invalid-format
:bottom-value 0})]] {:format (i18n/label :t/wakuv2-node-format)}))
(when-not new-node? :bottom-value 0})]]
[delete-button id])]] (when-not new-node?
[toolbar/toolbar [delete-button id])]]
{:right [toolbar/toolbar
[quo/button {:right
{:type :secondary [quo/button
:after :main-icon/next {:type :secondary
:disabled (not is-valid?) :after :main-icon/next
:on-press #(re-frame/dispatch [:wakuv2.ui/save-node-pressed])} :disabled (not is-valid?)
(i18n/label :t/save)]}]]))) :on-press #(re-frame/dispatch [:wakuv2.ui/save-node-pressed])}
(i18n/label :t/save)]}]]])))

View File

@ -8,6 +8,7 @@
[legacy.status-im.ui.components.topbar :as topbar] [legacy.status-im.ui.components.topbar :as topbar]
[legacy.status-im.ui.screens.wakuv2-settings.styles :as styles] [legacy.status-im.ui.screens.wakuv2-settings.styles :as styles]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[react-native.safe-area :as safe-area]
[utils.i18n :as i18n])) [utils.i18n :as i18n]))
(defn navigate-to-add-node (defn navigate-to-add-node
@ -27,7 +28,7 @@
(views/defview wakuv2-settings (views/defview wakuv2-settings
[] []
(views/letsubs [nodes [:wakuv2-nodes/list]] (views/letsubs [nodes [:wakuv2-nodes/list]]
[:<> [react/view {:flex 1 :padding-bottom (safe-area/get-bottom)}
[topbar/topbar [topbar/topbar
{:title (i18n/label :t/wakuv2-settings) {:title (i18n/label :t/wakuv2-settings)
:navigation :none :navigation :none

View File

@ -185,3 +185,12 @@
:crypto [] :crypto []
:other []} :other []}
(vals currencies))))) (vals currencies)))))
(re-frame/reg-sub
:wakuv2-nodes/validation-errors
:<- [:wakuv2-nodes/manage]
(fn [manage]
(set (keep
(fn [[k {:keys [error]}]]
(when error k))
manage))))