[#11236] Deeplink to public chat on onboarding

Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
andrey 2020-11-12 11:41:25 +01:00
parent a91bdfb047
commit cf911aa246
No known key found for this signature in database
GPG Key ID: 89B67245FD2F0272
2 changed files with 10 additions and 7 deletions

View File

@ -8,18 +8,20 @@
[status-im.chat.models :as chat]))
(fx/defn start-acquisition
[{:keys [db] :as cofx} {:keys [key] :as referrer}]
{:db (assoc-in db [:acquisition :chat-referrer key] referrer)
[{:keys [db]} {:keys [key id] :as referrer} public]
{:db (assoc-in db [:acquisition :chat-referrer (or key id)] referrer)
::persistence/chat-initialized? (fn [state]
(when-not (= "initialized" state)
(re-frame/dispatch [::start-chat referrer])))})
(re-frame/dispatch [::start-chat referrer public])))})
(fx/defn start-chat
{:events [::start-chat]}
[cofx {:keys [key] :as referrer}]
[cofx {:keys [key id]} public]
(fx/merge cofx
{::persistence/chat-initalized! true}
(chat/start-chat key)))
(if public
(chat/start-public-chat id nil)
(chat/start-chat key))))
(fx/defn accept-pack
{:events [::accept-pack]}

View File

@ -17,6 +17,7 @@
(def not-found-code "notfound.click_id")
(def advertiser-type "advertiser")
(def chat-type "chat")
(def chat-public-type "public-chat")
(def dapp-type "dapp")
(fx/defn handle-registration
@ -62,8 +63,8 @@
(= type advertiser-type)
(advertiser/start-acquisition referrer-meta)
(= type chat-type)
(chat/start-acquisition referrer-meta)
(#{chat-type chat-public-type} type)
(chat/start-acquisition referrer-meta (= type chat-public-type))
(= type dapp-type)
(dapp/start-acquisition referrer-meta)))))