Connection status info (#6865)

* display mailserver state and peers count under advanced settings on
the desktop profile tab
This commit is contained in:
Rob Culliton 2018-11-29 10:16:41 -05:00 committed by GitHub
parent ee7f98adb1
commit 91e5ac3ccd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 2 deletions

View File

@ -163,6 +163,10 @@
{:margin 24 {:margin 24
:font-size 20}) :font-size 20})
(def connection-message-text
{:margin-left 24
:margin-bottom 10})
(def title-separator (def title-separator
{:height 1 {:height 1
:background-color colors/gray-light}) :background-color colors/gray-light})

View File

@ -84,15 +84,37 @@
[pairing.views/sync-devices] [pairing.views/sync-devices]
[pairing.views/installations-list installations]]) [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/defview advanced-settings []
(views/letsubs [installations [:pairing/installations] (views/letsubs [installations [:pairing/installations]
current-mailserver-id [:mailserver/current-id] current-mailserver-id [:mailserver/current-id]
mailservers [:mailserver/fleet-mailservers]] mailservers [:mailserver/fleet-mailservers]
(let [render-fn (offline-messaging.views/render-row current-mailserver-id)] 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/scroll-view
[react/text {:style styles/advanced-settings-title [react/text {:style styles/advanced-settings-title
:font :medium} :font :medium}
(i18n/label :advanced-settings)] (i18n/label :advanced-settings)]
[react/view
[react/text {:style styles/connection-message-text} connection-message]]
[react/view {:style styles/title-separator}] [react/view {:style styles/title-separator}]
[react/text {:style styles/mailserver-title} (i18n/label :offline-messaging)] [react/text {:style styles/mailserver-title} (i18n/label :offline-messaging)]
[react/view [react/view

View File

@ -47,6 +47,7 @@
(reg-sub :sync-state :sync-state) (reg-sub :sync-state :sync-state)
(reg-sub :network-status :network-status) (reg-sub :network-status :network-status)
(reg-sub :peers-count :peers-count) (reg-sub :peers-count :peers-count)
(reg-sub :node-status :node/status)
(reg-sub :disconnected? (reg-sub :disconnected?
:<- [:peers-count] :<- [:peers-count]