Skip to content

Commit

Permalink
Add Test Networks Enabled option in settings (#17879)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayesivan authored Dec 12, 2023
1 parent fc8590a commit e5179d3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/status_im/ui/screens/advanced_settings/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
transactions-management-enabled?
wakuv2-flag
current-fleet
webview-debug]}]
webview-debug
test-networks-enabled?]}]
(keep
identity
[{:size :small
Expand Down Expand Up @@ -100,6 +101,14 @@
[:profile.settings/change-webview-debug (not webview-debug)])
:accessory :switch
:active webview-debug}
{:size :small
:title "Testnet mode"
:accessibility-label :test-networks-enabled
:container-margin-bottom 8
:on-press
#(re-frame/dispatch [:profile.settings/toggle-test-networks])
:accessory :switch
:active test-networks-enabled?}
{:size :small
:title (i18n/label :t/waku-bloom-filter-mode)
:accessibility-label :waku-bloom-filter-mode-settings-switch
Expand Down Expand Up @@ -128,7 +137,8 @@

(views/defview advanced-settings
[]
(views/letsubs [{:keys [webview-debug]} [:profile/profile]
(views/letsubs [{:keys [webview-debug
test-networks-enabled?]} [:profile/profile]
network-name [:network-name]
waku-bloom-filter-mode [:waku/bloom-filter-mode]
wakuv2-flag [:waku/v2-flag]
Expand All @@ -144,6 +154,7 @@
:dev-mode? false
:wakuv2-flag wakuv2-flag
:waku-bloom-filter-mode waku-bloom-filter-mode
:webview-debug webview-debug})
:webview-debug webview-debug
:test-networks-enabled? test-networks-enabled?})
:key-fn (fn [_ i] (str i))
:render-fn render-item}]))
1 change: 1 addition & 0 deletions src/status_im2/contexts/communities/discover/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@

(defn- internal-discover-view
[params]
(rf/dispatch [:fetch-contract-communities])
[:f> f-view-internal params])

(def view (quo.theme/with-theme internal-discover-view))
14 changes: 14 additions & 0 deletions src/status_im2/contexts/profile/settings/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[status-im2.constants :as constants]
status-im2.contexts.profile.settings.effects
[taoensso.timbre :as log]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))

(rf/defn send-contact-update
Expand All @@ -14,6 +15,7 @@
:on-success #(log/debug "sent contact update")}]}))

(rf/defn profile-update
{:events [:profile.settings/profile-update]}
[{:keys [db] :as cofx}
setting setting-value
{:keys [dont-sync? on-success] :or {on-success #()}}]
Expand Down Expand Up @@ -56,6 +58,18 @@
{:profile.settings/webview-debug-changed value}
(profile-update :webview-debug (boolean value) {})))

(rf/reg-event-fx :profile.settings/toggle-test-networks
(fn [{:keys [db]}]
(let [value (get-in db [:profile/profile :test-networks-enabled?])
on-success #(rf/dispatch [:logout])]
{:fx [[:ui/show-confirmation
{:title (i18n/label :t/testnet-mode-prompt-title)
:content (i18n/label :t/testnet-mode-prompt-content)
:on-accept #(rf/dispatch [:profile.settings/profile-update :test-networks-enabled?
(not value)
{:on-success on-success}])
:on-cancel nil}]]})))

(rf/defn change-preview-privacy-flag
{:events [:profile.settings/change-preview-privacy]}
[{:keys [db] :as cofx} private?]
Expand Down
2 changes: 2 additions & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,8 @@
"try-keeping-the-card-still": "Try keeping the card still",
"turn-nfc-on": "Turn NFC on to continue",
"turn-nfc-description": "NFC is disabled on yor device. You can enable it in settings",
"testnet-mode-prompt-title": "Warning!",
"testnet-mode-prompt-content": "You are about to switch the network mode. This will log you out and you will have to login again.",
"keycard-init-title": "Looking for cards...",
"keycard-init-description": "Put the card to the back of your phone to continue",
"keycard-awaiting-title": "Still looking...",
Expand Down

0 comments on commit e5179d3

Please sign in to comment.