diff --git a/src/status_im/ui/screens/desktop/main/tabs/profile/styles.cljs b/src/status_im/ui/screens/desktop/main/tabs/profile/styles.cljs index 3edbf0e71b..79968654cd 100644 --- a/src/status_im/ui/screens/desktop/main/tabs/profile/styles.cljs +++ b/src/status_im/ui/screens/desktop/main/tabs/profile/styles.cljs @@ -163,6 +163,10 @@ {:margin 24 :font-size 20}) +(def connection-message-text + {:margin-left 24 + :margin-bottom 10}) + (def title-separator {:height 1 :background-color colors/gray-light}) diff --git a/src/status_im/ui/screens/desktop/main/tabs/profile/views.cljs b/src/status_im/ui/screens/desktop/main/tabs/profile/views.cljs index bac10be7ab..9ab45661fd 100644 --- a/src/status_im/ui/screens/desktop/main/tabs/profile/views.cljs +++ b/src/status_im/ui/screens/desktop/main/tabs/profile/views.cljs @@ -84,15 +84,37 @@ [pairing.views/sync-devices] [pairing.views/installations-list installations]]) +(defn connection-status + "generates a composite message of the current connection state given peer and mailserver statuses" + [peers-count node-status mailserver-state peers-disconnected?] + ;; TODO probably not ideal criteria for searching + ;; ask about directly calling rpc method to find discovery.started + (let [searching? (= :starting node-status) + peers-connected? (not peers-disconnected?) + mailserver-connected? (= :connected mailserver-state)] + (cond + (and peers-connected? searching?) "Connected and searching" + (and peers-connected? (not mailserver-connected?)) (str "Connected with " peers-count " peers") + (and peers-connected? mailserver-connected?) (str "Connected with " peers-count " peers including mailserver.") + (and peers-disconnected? searching?) "Disconnected and searching" + :else "Disconnected"))) + (views/defview advanced-settings [] (views/letsubs [installations [:pairing/installations] current-mailserver-id [:mailserver/current-id] - mailservers [:mailserver/fleet-mailservers]] - (let [render-fn (offline-messaging.views/render-row current-mailserver-id)] + mailservers [:mailserver/fleet-mailservers] + mailserver-state [:mailserver/state] + node-status [:node-status] + peers-count [:peers-count] + disconnected [:disconnected?]] + (let [render-fn (offline-messaging.views/render-row current-mailserver-id) + connection-message (connection-status peers-count node-status mailserver-state disconnected)] [react/scroll-view [react/text {:style styles/advanced-settings-title :font :medium} (i18n/label :advanced-settings)] + [react/view + [react/text {:style styles/connection-message-text} connection-message]] [react/view {:style styles/title-separator}] [react/text {:style styles/mailserver-title} (i18n/label :offline-messaging)] [react/view diff --git a/src/status_im/ui/screens/subs.cljs b/src/status_im/ui/screens/subs.cljs index 12cbe056b1..565d04dcd1 100644 --- a/src/status_im/ui/screens/subs.cljs +++ b/src/status_im/ui/screens/subs.cljs @@ -47,6 +47,7 @@ (reg-sub :sync-state :sync-state) (reg-sub :network-status :network-status) (reg-sub :peers-count :peers-count) +(reg-sub :node-status :node/status) (reg-sub :disconnected? :<- [:peers-count]