Skip to content

Commit

Permalink
[#7819] fix - avoid unnecessary effects when joining/syncing already …
Browse files Browse the repository at this point in the history
…active public chat
  • Loading branch information
bitsikka committed May 1, 2019
1 parent 428464d commit 8720ce4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
23 changes: 16 additions & 7 deletions src/status_im/chat/models.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
([cofx chat-id]
(public-chat? (get-chat cofx chat-id))))

(defn active-chat?
([chat]
(:is-active chat))
([cofx chat-id]
(active-chat? (get-chat cofx chat-id))))

(defn group-chat?
([chat]
(and (multi-user-chat? chat)
Expand Down Expand Up @@ -289,13 +295,16 @@
(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))))
(if (active-chat? cofx topic)
(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)))))

(fx/defn disable-chat-cooldown
"Turns off chat cooldown (protection against message spamming)"
Expand Down
1 change: 0 additions & 1 deletion src/status_im/pairing/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@
(let [contacts (:contacts/contacts db)
contact-batches (partition-all contact-batch-n (vals contacts))]
(concat (mapv contact-batch->sync-installation-message contact-batches)

[(sync-installation-account-message cofx)]
(chats->sync-installation-messages cofx))))

Expand Down
6 changes: 5 additions & 1 deletion src/status_im/utils/universal_links/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[re-frame.core :as re-frame]
[status-im.accounts.db :as accounts.db]
[status-im.chat.models :as chat]
[status-im.pairing.core :as pairing]
[status-im.extensions.registry :as extensions.registry]
[status-im.ui.components.list-selection :as list-selection]
[status-im.ui.components.react :as react]
Expand Down Expand Up @@ -65,7 +66,10 @@

(fx/defn handle-public-chat [cofx public-chat]
(log/info "universal-links: handling public chat" public-chat)
(chat/start-public-chat cofx public-chat {}))
(fx/merge
cofx
(chat/start-public-chat public-chat {})
(pairing/sync-public-chat public-chat)))

(fx/defn handle-view-profile [{:keys [db] :as cofx} public-key]
(log/info "universal-links: handling view profile" public-key)
Expand Down

0 comments on commit 8720ce4

Please sign in to comment.