From b11d3bed780cfb7f3dea8bd7f7bd1780d15200dc Mon Sep 17 00:00:00 2001 From: flexsurfer Date: Tue, 24 Sep 2024 17:00:51 +0200 Subject: [PATCH] Crash when trying to add Waku settings in Advanced Settings #21155 (#21302) --- .../wakuv2_settings/edit_node/views.cljs | 74 ++++++++++--------- .../ui/screens/wakuv2_settings/views.cljs | 3 +- src/status_im/subs/general.cljs | 9 +++ 3 files changed, 49 insertions(+), 37 deletions(-) diff --git a/src/legacy/status_im/ui/screens/wakuv2_settings/edit_node/views.cljs b/src/legacy/status_im/ui/screens/wakuv2_settings/edit_node/views.cljs index cbed155825..ae0da75fcf 100644 --- a/src/legacy/status_im/ui/screens/wakuv2_settings/edit_node/views.cljs +++ b/src/legacy/status_im/ui/screens/wakuv2_settings/edit_node/views.cljs @@ -7,6 +7,7 @@ [legacy.status-im.ui.components.topbar :as topbar] [legacy.status-im.ui.screens.wakuv2-settings.edit-node.styles :as styles] [re-frame.core :as re-frame] + [react-native.safe-area :as safe-area] [utils.i18n :as i18n]) (:require-macros [legacy.status-im.utils.views :as views])) @@ -33,39 +34,40 @@ [react/keyboard-avoiding-view {:style {:flex 1} :ignore-offset true} - [topbar/topbar {:title (i18n/label (if name :t/node-details :t/add-node))}] - [react/scroll-view {:keyboard-should-persist-taps :handled} - [react/view styles/edit-node-view - [react/view {:padding-vertical 8} - [quo/text-input - {:label (i18n/label :t/name) - :placeholder (i18n/label :t/specify-name) - :accessibility-label :node-name - :default-value name - :on-change-text #(re-frame/dispatch [:wakuv2.ui/input-changed :name %]) - :auto-focus true}]] - [react/view - {:flex 1 - :padding-vertical 8} - [quo/text-input - (merge - {:label (i18n/label :t/node-address) - :placeholder (i18n/label :t/wakuv2-node-format) - :accessibility-label :node-address - :default-value address - :show-cancel false - :on-change-text #(re-frame/dispatch [:wakuv2.ui/input-changed :address %]) - :error (when (and (not (string/blank? address)) invalid-address?) - (i18n/label :t/invalid-format - {:format (i18n/label :t/wakuv2-node-format)})) - :bottom-value 0})]] - (when-not new-node? - [delete-button id])]] - [toolbar/toolbar - {:right - [quo/button - {:type :secondary - :after :main-icon/next - :disabled (not is-valid?) - :on-press #(re-frame/dispatch [:wakuv2.ui/save-node-pressed])} - (i18n/label :t/save)]}]]))) + [react/view {:flex 1 :padding-bottom (safe-area/get-bottom)} + [topbar/topbar {:title (i18n/label (if name :t/node-details :t/add-node))}] + [react/scroll-view {:keyboard-should-persist-taps :handled} + [react/view styles/edit-node-view + [react/view {:padding-vertical 8} + [quo/text-input + {:label (i18n/label :t/name) + :placeholder (i18n/label :t/specify-name) + :accessibility-label :node-name + :default-value name + :on-change-text #(re-frame/dispatch [:wakuv2.ui/input-changed :name %]) + :auto-focus true}]] + [react/view + {:flex 1 + :padding-vertical 8} + [quo/text-input + (merge + {:label (i18n/label :t/node-address) + :placeholder (i18n/label :t/wakuv2-node-format) + :accessibility-label :node-address + :default-value address + :show-cancel false + :on-change-text #(re-frame/dispatch [:wakuv2.ui/input-changed :address %]) + :error (when (and (not (string/blank? address)) invalid-address?) + (i18n/label :t/invalid-format + {:format (i18n/label :t/wakuv2-node-format)})) + :bottom-value 0})]] + (when-not new-node? + [delete-button id])]] + [toolbar/toolbar + {:right + [quo/button + {:type :secondary + :after :main-icon/next + :disabled (not is-valid?) + :on-press #(re-frame/dispatch [:wakuv2.ui/save-node-pressed])} + (i18n/label :t/save)]}]]]))) diff --git a/src/legacy/status_im/ui/screens/wakuv2_settings/views.cljs b/src/legacy/status_im/ui/screens/wakuv2_settings/views.cljs index 2b1765f855..55553d9a21 100644 --- a/src/legacy/status_im/ui/screens/wakuv2_settings/views.cljs +++ b/src/legacy/status_im/ui/screens/wakuv2_settings/views.cljs @@ -8,6 +8,7 @@ [legacy.status-im.ui.components.topbar :as topbar] [legacy.status-im.ui.screens.wakuv2-settings.styles :as styles] [re-frame.core :as re-frame] + [react-native.safe-area :as safe-area] [utils.i18n :as i18n])) (defn navigate-to-add-node @@ -27,7 +28,7 @@ (views/defview wakuv2-settings [] (views/letsubs [nodes [:wakuv2-nodes/list]] - [:<> + [react/view {:flex 1 :padding-bottom (safe-area/get-bottom)} [topbar/topbar {:title (i18n/label :t/wakuv2-settings) :navigation :none diff --git a/src/status_im/subs/general.cljs b/src/status_im/subs/general.cljs index 9bbb06e693..50b1b01c52 100644 --- a/src/status_im/subs/general.cljs +++ b/src/status_im/subs/general.cljs @@ -185,3 +185,12 @@ :crypto [] :other []} (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))))