Skip to content

Commit 1e5b686

Browse files
committed
Disable send button when no peers are connected.
Previously we were only checking whether `network-status` is equal to `:offline`, therefore allowing the user to send messages even when no peers are connected (i.e. the app is displaying Connecting to peers..). Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
1 parent 3b494cf commit 1e5b686

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

src/status_im/ui/screens/chat/input/send_button.cljs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414
(animation/timing spin-value {:toValue to-spin-value
1515
:duration 300})))))
1616

17-
(defn sendable? [input-text network-status]
17+
(defn sendable? [input-text offline?]
1818
(let [trimmed (string/trim input-text)]
1919
(not (or (string/blank? trimmed)
2020
(= trimmed "/")
21-
(= :offline network-status)))))
21+
offline?))))
2222

2323
(defview send-button-view []
2424
(letsubs [{:keys [command-completion]} [:chats/selected-chat-command]
2525
{:keys [input-text seq-arg-input-text]} [:chats/current-chat]
26-
network-status [:network-status]
26+
offline? [:offline?]
2727
spin-value (animation/create-value 1)]
2828
{:component-did-update (send-button-view-on-update {:spin-value spin-value
2929
:command-completion command-completion})}
30-
(when (and (sendable? input-text network-status)
30+
(when (and (sendable? input-text offline?)
3131
(or (not command-completion)
3232
(#{:complete :less-than-needed} command-completion)))
3333
[react/touchable-highlight {:on-press #(re-frame/dispatch [:chat.ui/send-current-message])}

src/status_im/ui/screens/subs.cljs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,20 @@
4848
(reg-sub :network-status :network-status)
4949
(reg-sub :peers-count :peers-count)
5050

51-
(reg-sub :offline?
52-
:<- [:network-status]
53-
:<- [:sync-state]
54-
(fn [[network-status sync-state]]
55-
(or (= network-status :offline)
56-
(= sync-state :offline))))
57-
5851
(reg-sub :disconnected?
5952
:<- [:peers-count]
6053
(fn [peers-count]
6154
(zero? peers-count)))
6255

56+
(reg-sub :offline?
57+
:<- [:network-status]
58+
:<- [:sync-state]
59+
:<- [:disconnected?]
60+
(fn [[network-status sync-state disconnected?]]
61+
(or disconnected?
62+
(= network-status :offline)
63+
(= sync-state :offline))))
64+
6365
(reg-sub :syncing?
6466
:<- [:sync-state]
6567
(fn [sync-state]

0 commit comments

Comments
 (0)