Skip to content

Commit

Permalink
[#7819] fix avoid unnecessary steps when (re)starting new chat
Browse files Browse the repository at this point in the history
[#7819] fix avoid unnecessary steps when (re)starting new chat

[#7819] fix avoid unnecessary steps when (re)starting new chat

[#7819] fix avoid unnecessary steps when (re)starting new chat

[#7819] fix avoid unnecessary steps when (re)starting new chat

[#7819] fix avoid unnecessary steps when (re)starting new chat

[#7819] fix avoid unnecessary steps when (re)starting new chat
  • Loading branch information
bitsikka committed Apr 8, 2019
1 parent 747ca2b commit cc940de
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
27 changes: 19 additions & 8 deletions src/status_im/chat/models.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,25 @@

(fx/defn start-public-chat
"Starts a new public chat"
[cofx topic {:keys [dont-navigate?] :as opts}]
(fx/merge cofx
(add-public-chat topic)
#(when-not dont-navigate?
(navigate-to-chat % topic opts))
(public-chat/join-public-chat topic)
(when platform/desktop?
(desktop.events/change-tab :home))))
[cofx topic {:keys [dont-navigate? sync?] :or {sync? true} :as opts}]
(let [chats (into []
(comp (filter :is-active)
(filter :public?)
(filter #(= topic (:chat-id %))))
(vals (get-in cofx [:db :chats])))
already-active? (seq chats)]
(if already-active?
(when-not dont-navigate?
(navigate-to-chat cofx topic opts))
(fx/merge cofx
(add-public-chat topic)
#(when-not dont-navigate?
(navigate-to-chat % topic opts))
(public-chat/join-public-chat topic)
#(when platform/desktop?
(desktop.events/change-tab % :home))
#(when sync?
{:dispatch [:chat.ui/sync-public-chat topic]})))))

(fx/defn disable-chat-cooldown
"Turns off chat cooldown (protection against message spamming)"
Expand Down
10 changes: 6 additions & 4 deletions src/status_im/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -769,10 +769,12 @@
(handlers/register-handler-fx
:chat.ui/start-public-chat
(fn [cofx [_ topic opts]]
(fx/merge
cofx
(chat/start-public-chat topic opts)
(pairing/sync-public-chat topic))))
(chat/start-public-chat cofx topic opts)))

(handlers/register-handler-fx
:chat.ui/sync-public-chat
(fn [cofx [_ topic]]
(pairing/sync-public-chat cofx topic)))

(handlers/register-handler-fx
:chat.ui/remove-chat
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/pairing/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
:data-store/base-tx [{:transaction (data-store.accounts/save-account-tx new-account)
:success-event success-event}]}
#(when (:public? chat)
(models.chat/start-public-chat % (:chat-id chat) {:dont-navigate? true}))]
(models.chat/start-public-chat % (:chat-id chat) {:dont-navigate? true :sync? false}))]
contacts-fx)))
(confirm-message-processed cofx (or (:dedup-id cofx)
(:js-obj cofx)))))
Expand Down

0 comments on commit cc940de

Please sign in to comment.