Add Test Networks Enabled option in settings (#17879)

This commit is contained in:
Ajay Sivan 2023-12-12 14:06:43 +05:30 committed by GitHub
parent fc8590a05f
commit e5179d308b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 3 deletions

View File

@ -19,7 +19,8 @@
transactions-management-enabled?
wakuv2-flag
current-fleet
webview-debug]}]
webview-debug
test-networks-enabled?]}]
(keep
identity
[{:size :small
@ -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
@ -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]
@ -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}]))

View File

@ -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))

View File

@ -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
@ -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 #()}}]
@ -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?]

View File

@ -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...",