From 93db31d867ab8011a9e854eb78892c6c8993a752 Mon Sep 17 00:00:00 2001 From: yenda Date: Thu, 8 Nov 2018 09:57:46 +0100 Subject: [PATCH] [6628] don't block message sending when mailserver disconnected Signed-off-by: Dmitry Novotochinov --- src/status_im/mailserver/subs.cljs | 6 ------ src/status_im/ui/screens/chat/input/send_button.cljs | 8 +++----- .../ui/screens/desktop/main/chat/views.cljs | 12 +++++------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/status_im/mailserver/subs.cljs b/src/status_im/mailserver/subs.cljs index da20ce955a..c85aa85a53 100644 --- a/src/status_im/mailserver/subs.cljs +++ b/src/status_im/mailserver/subs.cljs @@ -27,12 +27,6 @@ (fn [state] (#{:error :disconnected} state))) -(re-frame/reg-sub - :mailserver/connected? - :<- [:mailserver/state] - (fn [state] - (= :connected state))) - (re-frame/reg-sub :mailserver/current-id (fn [db] diff --git a/src/status_im/ui/screens/chat/input/send_button.cljs b/src/status_im/ui/screens/chat/input/send_button.cljs index aa8c35e62c..ed9736892b 100644 --- a/src/status_im/ui/screens/chat/input/send_button.cljs +++ b/src/status_im/ui/screens/chat/input/send_button.cljs @@ -14,22 +14,20 @@ (animation/timing spin-value {:toValue to-spin-value :duration 300}))))) -(defn sendable? [input-text network-status mailserver-connected?] +(defn sendable? [input-text network-status] (let [trimmed (string/trim input-text)] (not (or (string/blank? trimmed) (= trimmed "/") - (= :offline network-status) - (not mailserver-connected?))))) + (= :offline network-status))))) (defview send-button-view [] (letsubs [{:keys [command-completion]} [:selected-chat-command] {:keys [input-text seq-arg-input-text]} [:get-current-chat] network-status [:network-status] - mailserver-connected? [:mailserver/connected?] spin-value (animation/create-value 1)] {:component-did-update (send-button-view-on-update {:spin-value spin-value :command-completion command-completion})} - (when (and (sendable? input-text network-status mailserver-connected?) + (when (and (sendable? input-text network-status) (or (not command-completion) (#{:complete :less-than-needed} command-completion))) [react/touchable-highlight {:on-press #(re-frame/dispatch [:chat.ui/send-current-message])} diff --git a/src/status_im/ui/screens/desktop/main/chat/views.cljs b/src/status_im/ui/screens/desktop/main/chat/views.cljs index 00d095655e..89578c07ff 100644 --- a/src/status_im/ui/screens/desktop/main/chat/views.cljs +++ b/src/status_im/ui/screens/desktop/main/chat/views.cljs @@ -242,11 +242,11 @@ :current-public-key current-public-key)]))]] [connectivity/error-view]]))) -(views/defview send-button [inp-ref network-status mailserver-connected?] +(views/defview send-button [inp-ref network-status] (views/letsubs [{:keys [input-text]} [:get-current-chat]] (let [empty? (= "" input-text) offline? (= :offline network-status) - inactive? (or empty? offline? (not mailserver-connected?))] + inactive? (or empty? offline?)] [react/touchable-highlight {:style styles/send-button :disabled inactive? :on-press (fn [] @@ -288,8 +288,7 @@ (views/defview chat-text-input [chat-id input-text] (views/letsubs [inp-ref (atom nil) - network-status [:network-status] - mailserver-connected? [:mailserver/connected?]] + network-status [:network-status]] {:component-will-update (fn [e [_ new-chat-id new-input-text]] (let [[_ old-chat-id] (.. e -props -argv)] @@ -310,8 +309,7 @@ :default-value input-text :on-content-size-change #(set-container-height-fn (.-height (.-contentSize (.-nativeEvent %)))) :submit-shortcut {:key "Enter"} - :on-submit-editing #(when (and (= :online network-status) - mailserver-connected?) + :on-submit-editing #(when (= :online network-status) (.clear @inp-ref) (.focus @inp-ref) (re-frame/dispatch [:chat.ui/send-current-message])) @@ -319,7 +317,7 @@ (let [native-event (.-nativeEvent e) text (.-text native-event)] (re-frame/dispatch [:chat.ui/set-chat-input-text text])))}] - [send-button inp-ref network-status mailserver-connected?]]))) + [send-button inp-ref network-status]]))) (views/defview chat-view [] (views/letsubs [{:keys [input-text chat-id] :as current-chat} [:get-current-chat]]