hide dev mode setting

This commit is contained in:
Andrey Shovkoplyas 2019-12-16 15:31:02 +01:00
parent 2c3e831a03
commit b84139013a
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
4 changed files with 23 additions and 128 deletions

View File

@ -116,21 +116,6 @@
(fn [cofx [_ desktop-notifications?]] (fn [cofx [_ desktop-notifications?]]
(multiaccounts/enable-notifications cofx desktop-notifications?))) (multiaccounts/enable-notifications cofx desktop-notifications?)))
(handlers/register-handler-fx
:multiaccounts.ui/toggle-datasync
(fn [cofx [_ enabled?]]
(multiaccounts/toggle-datasync cofx enabled?)))
(handlers/register-handler-fx
:multiaccounts.ui/toggle-v1-messages
(fn [cofx [_ enabled?]]
(multiaccounts/toggle-v1-messages cofx enabled?)))
(handlers/register-handler-fx
:multiaccounts.ui/toggle-disable-discovery-topic
(fn [cofx [_ enabled?]]
(multiaccounts/toggle-disable-discovery-topic cofx enabled?)))
(handlers/register-handler-fx (handlers/register-handler-fx
:multiaccounts.ui/preview-privacy-mode-switched :multiaccounts.ui/preview-privacy-mode-switched
(fn [cofx [_ private?]] (fn [cofx [_ private?]]

View File

@ -90,47 +90,6 @@
{:desktop-notifications? desktop-notifications?} {:desktop-notifications? desktop-notifications?}
{})) {}))
(fx/defn toggle-datasync
[{:keys [db] :as cofx} enabled?]
(let [settings (get-in db [:multiaccount :settings])
warning {:utils/show-popup
{:title (i18n/label :t/datasync-warning-title)
:content (i18n/label :t/datasync-warning-content)}}]
(fx/merge cofx
(when enabled? warning)
(multiaccounts.update/update-settings
(assoc settings :datasync? enabled?)
{}))))
(fx/defn toggle-v1-messages
[{:keys [db] :as cofx} enabled?]
(let [settings (get-in db [:multiaccount :settings])
warning {:utils/show-popup
{:title (i18n/label :t/v1-messages-warning-title)
:content (i18n/label :t/v1-messages-warning-content)}}]
(fx/merge cofx
(when enabled? warning)
(multiaccounts.update/update-settings
(assoc settings :v1-messages? enabled?)
{}))))
(fx/defn toggle-disable-discovery-topic
[{:keys [db] :as cofx} enabled?]
(let [settings (get-in db [:multiaccount :settings])
warning {:utils/show-popup
{:title
(i18n/label :t/disable-discovery-topic-warning-title)
:content
(i18n/label :t/disable-discovery-topic-warning-content)}}]
(fx/merge cofx
(when enabled? warning)
(multiaccounts.update/update-settings
(assoc settings :disable-discovery-topic? enabled?)
{}))))
(fx/defn switch-preview-privacy-mode (fx/defn switch-preview-privacy-mode
[{:keys [db] :as cofx} private?] [{:keys [db] :as cofx} private?]
(let [settings (get-in db [:multiaccount :settings])] (let [settings (get-in db [:multiaccount :settings])]

View File

@ -103,10 +103,7 @@
{:keys [installation-id settings bootnodes] {:keys [installation-id settings bootnodes]
:or {settings constants/default-multiaccount-settings}} multiaccount :or {settings constants/default-multiaccount-settings}} multiaccount
use-custom-bootnodes (get-in settings [:bootnodes current-network]) use-custom-bootnodes (get-in settings [:bootnodes current-network])
log-level (get-log-level settings) log-level (get-log-level settings)]
datasync? (:datasync? settings)
disable-discovery-topic? (:disable-discovery-topic? settings)
v1-messages? (:v1-messages? settings)]
(cond-> (get-in networks [current-network :config]) (cond-> (get-in networks [current-network :config])
:always :always
(get-base-node-config) (get-base-node-config)
@ -140,9 +137,7 @@
:InstallationID installation-id :InstallationID installation-id
:MaxMessageDeliveryAttempts config/max-message-delivery-attempts :MaxMessageDeliveryAttempts config/max-message-delivery-attempts
:MailServerConfirmations config/mailserver-confirmations-enabled? :MailServerConfirmations config/mailserver-confirmations-enabled?
:DataSyncEnabled (boolean datasync?) :DataSyncEnabled true
:DisableGenericDiscoveryTopic (boolean disable-discovery-topic?)
:SendV1Messages (boolean v1-messages?)
:PFSEnabled true} :PFSEnabled true}
:RequireTopics (get-topics current-network) :RequireTopics (get-topics current-network)
:StatusAccountsConfig {:Enabled true}) :StatusAccountsConfig {:Enabled true})

View File

@ -39,69 +39,27 @@
:on-press :on-press
#(re-frame/dispatch [:navigate-to :bootnodes-settings]) #(re-frame/dispatch [:navigate-to :bootnodes-settings])
:accessories [:chevron]} :accessories [:chevron]}
{:type :small #_{:type :small
:title :t/dev-mode :title :t/dev-mode
:accessibility-label :dev-mode-settings-switch :accessibility-label :dev-mode-settings-switch
:container-margin-bottom 8 :container-margin-bottom 8
:on-press :on-press
#(re-frame/dispatch #(re-frame/dispatch
[:multiaccounts.ui/dev-mode-switched (not dev-mode?)]) [:multiaccounts.ui/dev-mode-switched (not dev-mode?)])
:accessories :accessories
[[react/switch [[react/switch
{:track-color #js {:true colors/blue :false nil} {:track-color #js {:true colors/blue :false nil}
:value dev-mode? :value dev-mode?
:on-value-change :on-value-change
#(re-frame/dispatch #(re-frame/dispatch
[:multiaccounts.ui/dev-mode-switched (not dev-mode?)]) [:multiaccounts.ui/dev-mode-switched (not dev-mode?)])
:disabled false}]]} :disabled false}]]}
{:type :divider}]) #_{:type :divider}])
(defn- dev-mode-settings-data [settings chaos-mode?] (defn- dev-mode-settings-data [chaos-mode?]
[{:container-margin-top 8 [{:container-margin-top 8
:type :section-header :type :section-header
:title :t/dev-mode-settings} :title :t/dev-mode-settings}
{:type :small
:title :t/datasync
:accessibility-label :datasync-settings-switch
:accessories
[[react/switch
{:track-color #js {:true colors/blue :false nil}
:value (boolean (:datasync? settings))
:on-value-change
#(re-frame/dispatch [:multiaccounts.ui/toggle-datasync %])
:disabled false}]]
:on-press
#(re-frame/dispatch
[:multiaccounts.ui/toggle-datasync
((complement boolean) (:datasync? settings))])}
{:type :small
:title :t/v1-messages
:accessibility-label :v1-messages-settings-switch
:accessories
[[react/switch
{:track-color #js {:true colors/blue :false nil}
:value (boolean (:v1-messages? settings))
:on-value-change
#(re-frame/dispatch [:multiaccounts.ui/toggle-v1-messages %])
:disabled false}]]
:on-press
#(re-frame/dispatch
[:multiaccounts.ui/toggle-v1-messages
((complement boolean) (:v1-messages? settings))])}
{:type :small
:title :t/disable-discovery-topic
:accessibility-label :discovery-topic-settings-switch
:accessories
[[react/switch
{:track-color #js {:true colors/blue :false nil}
:value (boolean (:disable-discovery-topic? settings))
:on-value-change
#(re-frame/dispatch [:multiaccounts.ui/toggle-disable-discovery-topic %])
:disabled false}]]
:on-press
#(re-frame/dispatch
[:multiaccounts.ui/toggle-disable-discovery-topic
((complement boolean) (:disable-discovery-topic? settings))])}
{:type :small {:type :small
:title :t/chaos-mode :title :t/chaos-mode
:accessibility-label :chaos-mode-settings-switch :accessibility-label :chaos-mode-settings-switch
@ -119,19 +77,18 @@
[react/view {:height 24}]]) [react/view {:height 24}]])
(defn- flat-list-data [network-name current-log-level current-fleet (defn- flat-list-data [network-name current-log-level current-fleet
dev-mode? settings chaos-mode?] dev-mode? chaos-mode?]
(if dev-mode? (if dev-mode?
(into (into
(normal-mode-settings-data (normal-mode-settings-data
network-name current-log-level current-fleet dev-mode?) network-name current-log-level current-fleet dev-mode?)
(dev-mode-settings-data (dev-mode-settings-data chaos-mode?))
settings chaos-mode?))
;; else ;; else
(normal-mode-settings-data (normal-mode-settings-data
network-name current-log-level current-fleet dev-mode?))) network-name current-log-level current-fleet dev-mode?)))
(views/defview advanced-settings [] (views/defview advanced-settings []
(views/letsubs [{:keys [chaos-mode? dev-mode? settings]} [:multiaccount] (views/letsubs [{:keys [chaos-mode?]} [:multiaccount]
network-name [:network-name] network-name [:network-name]
current-log-level [:settings/current-log-level] current-log-level [:settings/current-log-level]
current-fleet [:settings/current-fleet]] current-fleet [:settings/current-fleet]]
@ -141,8 +98,7 @@
[list/flat-list [list/flat-list
{:data (flat-list-data {:data (flat-list-data
network-name current-log-level network-name current-log-level
current-fleet dev-mode? settings current-fleet false chaos-mode?)
chaos-mode?)
:key-fn (fn [_ i] (str i)) :key-fn (fn [_ i] (str i))
:render-fn list/flat-list-generic-render-fn}]])) :render-fn list/flat-list-generic-render-fn}]]))