[#13357] 'Unknown Not a contact' screen with endless spinner when starting new 1-1 or public chat / opening it via push notification (#13379)
This commit is contained in:
parent
e4cba0f663
commit
a4b169efa3
|
@ -204,14 +204,11 @@
|
||||||
(fx/defn close-chat
|
(fx/defn close-chat
|
||||||
{:events [:close-chat]}
|
{:events [:close-chat]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(let [chat-id (:current-chat-id db)
|
(when-let [chat-id (:current-chat-id db)]
|
||||||
navigate-after-home-to-chat (:navigate-after-home-to-chat db)]
|
|
||||||
(chat.state/reset-visible-item)
|
(chat.state/reset-visible-item)
|
||||||
(if navigate-after-home-to-chat
|
(fx/merge cofx
|
||||||
{:db (dissoc db :navigate-after-home-to-chat)}
|
{:db (dissoc db :current-chat-id)}
|
||||||
(fx/merge cofx
|
(offload-messages chat-id))))
|
||||||
{:db (dissoc db :current-chat-id)}
|
|
||||||
(offload-messages chat-id)))))
|
|
||||||
|
|
||||||
(fx/defn force-close-chat
|
(fx/defn force-close-chat
|
||||||
[{:keys [db] :as cofx} chat-id]
|
[{:keys [db] :as cofx} chat-id]
|
||||||
|
@ -249,20 +246,17 @@
|
||||||
"Takes coeffects map and chat-id, returns effects necessary for navigation and preloading data"
|
"Takes coeffects map and chat-id, returns effects necessary for navigation and preloading data"
|
||||||
{:events [:chat.ui/navigate-to-chat]}
|
{:events [:chat.ui/navigate-to-chat]}
|
||||||
[{db :db :as cofx} chat-id]
|
[{db :db :as cofx} chat-id]
|
||||||
(let [home-view? (= (get db :view-id) :home)]
|
(fx/merge cofx
|
||||||
(fx/merge cofx
|
{:dispatch [:navigate-to :chat]}
|
||||||
(close-chat)
|
(navigation/change-tab :chat)
|
||||||
(force-close-chat chat-id)
|
(navigation/pop-to-root-tab :chat-stack)
|
||||||
(fn [{:keys [db]}]
|
(close-chat)
|
||||||
{:db (assoc db :current-chat-id chat-id :navigate-after-home-to-chat (not home-view?))})
|
(force-close-chat chat-id)
|
||||||
(preload-chat-data chat-id)
|
(fn [{:keys [db]}]
|
||||||
#(when (group-chat? cofx chat-id)
|
{:db (assoc db :current-chat-id chat-id)})
|
||||||
(loading/load-chat % chat-id))
|
(preload-chat-data chat-id)
|
||||||
#(when-not home-view?
|
#(when (group-chat? cofx chat-id)
|
||||||
(navigation/change-tab % :chat))
|
(loading/load-chat % chat-id))))
|
||||||
#(when-not home-view?
|
|
||||||
(navigation/pop-to-root-tab % :chat-stack))
|
|
||||||
(navigation/navigate-to-cofx :chat nil))))
|
|
||||||
|
|
||||||
(fx/defn navigate-to-chat-nav2
|
(fx/defn navigate-to-chat-nav2
|
||||||
"Takes coeffects map and chat-id, returns effects necessary for navigation and preloading data"
|
"Takes coeffects map and chat-id, returns effects necessary for navigation and preloading data"
|
||||||
|
@ -319,29 +313,28 @@
|
||||||
|
|
||||||
(fx/defn handle-public-chat-created
|
(fx/defn handle-public-chat-created
|
||||||
{:events [::public-chat-created]}
|
{:events [::public-chat-created]}
|
||||||
[{:keys [db]} chat-id _ response]
|
[{:keys [db]} chat-id response]
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(assoc-in [:chats chat-id] (chats-store/<-rpc (first (:chats response))))
|
(assoc-in [:chats chat-id] (chats-store/<-rpc (first (:chats response))))
|
||||||
(update :chats-home-list conj chat-id))
|
(update :chats-home-list conj chat-id))
|
||||||
:dispatch [:chat.ui/navigate-to-chat chat-id]})
|
:dispatch [:chat.ui/navigate-to-chat chat-id]})
|
||||||
|
|
||||||
(fx/defn create-public-chat-go [_ chat-id opts]
|
(fx/defn create-public-chat-go [_ chat-id]
|
||||||
{::json-rpc/call [{:method "wakuext_createPublicChat"
|
{::json-rpc/call [{:method "wakuext_createPublicChat"
|
||||||
:params [{:id chat-id}]
|
:params [{:id chat-id}]
|
||||||
:on-success #(re-frame/dispatch [::public-chat-created chat-id opts %])
|
:on-success #(re-frame/dispatch [::public-chat-created chat-id %])
|
||||||
:on-error #(log/error "failed to create public chat" chat-id %)}]})
|
:on-error #(log/error "failed to create public chat" chat-id %)}]})
|
||||||
|
|
||||||
(fx/defn start-public-chat
|
(fx/defn start-public-chat
|
||||||
"Starts a new public chat"
|
"Starts a new public chat"
|
||||||
{:events [:chat.ui/start-public-chat]}
|
{:events [:chat.ui/start-public-chat]}
|
||||||
[cofx topic {:keys [profile-public-key] :as opts}]
|
[cofx topic]
|
||||||
(if (or (new-public-chat.db/valid-topic? topic) profile-public-key)
|
(if (new-public-chat.db/valid-topic? topic)
|
||||||
(if (active-chat? cofx topic)
|
(if (active-chat? cofx topic)
|
||||||
(navigate-to-chat cofx topic)
|
(navigate-to-chat cofx topic)
|
||||||
(create-public-chat-go
|
(create-public-chat-go
|
||||||
cofx
|
cofx
|
||||||
topic
|
topic))
|
||||||
opts))
|
|
||||||
{:utils/show-popup {:title (i18n/label :t/cant-open-public-chat)
|
{:utils/show-popup {:title (i18n/label :t/cant-open-public-chat)
|
||||||
:content (i18n/label :t/invalid-public-chat-topic)}}))
|
:content (i18n/label :t/invalid-public-chat-topic)}}))
|
||||||
|
|
||||||
|
@ -500,4 +493,4 @@
|
||||||
(update-in [:chats chat-id :unviewed-messages-count]
|
(update-in [:chats chat-id :unviewed-messages-count]
|
||||||
#(max (- % count) 0))
|
#(max (- % count) 0))
|
||||||
(update-in [:chats chat-id :unviewed-mentions-count]
|
(update-in [:chats chat-id :unviewed-mentions-count]
|
||||||
#(max (- % countWithMentions) 0)))})
|
#(max (- % countWithMentions) 0)))})
|
|
@ -11,9 +11,8 @@
|
||||||
:interceptors [(re-frame/inject-cofx :random-id-generator)]}
|
:interceptors [(re-frame/inject-cofx :random-id-generator)]}
|
||||||
[cofx {:keys [public-key ens-name]}]
|
[cofx {:keys [public-key ens-name]}]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:dispatch-later [{:ms 1000 :dispatch [:chat.ui/start-chat public-key ens-name]}]}
|
(chat/start-chat public-key ens-name)
|
||||||
(notification-center/accept-all-activity-center-notifications-from-chat public-key)
|
(notification-center/accept-all-activity-center-notifications-from-chat public-key)))
|
||||||
(navigation/pop-to-root-tab :chat-stack)))
|
|
||||||
|
|
||||||
(fx/defn contact-code-submitted
|
(fx/defn contact-code-submitted
|
||||||
{:events [:contact.ui/contact-code-submitted]
|
{:events [:contact.ui/contact-code-submitted]
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
[status-im.wallet.core :as wallet]
|
[status-im.wallet.core :as wallet]
|
||||||
status-im.wallet.custom-tokens.core
|
status-im.wallet.custom-tokens.core
|
||||||
[status-im.navigation.core :as navigation.core]
|
[status-im.navigation.core :as navigation.core]
|
||||||
[status-im.multiaccounts.login.core :as login.core]
|
[status-im.navigation.state :as navigation.state]
|
||||||
[status-im.signing.core :as signing]
|
[status-im.signing.core :as signing]
|
||||||
status-im.wallet-connect.core
|
status-im.wallet-connect.core
|
||||||
status-im.wallet-connect-legacy.core
|
status-im.wallet-connect-legacy.core
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
current-tab (get db :current-tab :chat)
|
current-tab (get db :current-tab :chat)
|
||||||
view-id (:view-id db)
|
view-id (:view-id db)
|
||||||
screen-params (get-in db [:navigation/screen-params view-id])
|
screen-params (get-in db [:navigation/screen-params view-id])
|
||||||
root-id @navigation.core/root-id
|
root-id @navigation.state/root-id
|
||||||
dispatch-later (cond-> []
|
dispatch-later (cond-> []
|
||||||
(= view-id :chat)
|
(= view-id :chat)
|
||||||
(conj {:ms 1000
|
(conj {:ms 1000
|
||||||
|
|
|
@ -15,9 +15,7 @@
|
||||||
{:events [:navigate-chat-updated]}
|
{:events [:navigate-chat-updated]}
|
||||||
[cofx chat-id]
|
[cofx chat-id]
|
||||||
(when (get-in cofx [:db :chats chat-id])
|
(when (get-in cofx [:db :chats chat-id])
|
||||||
(fx/merge cofx
|
(models.chat/navigate-to-chat cofx chat-id)))
|
||||||
{:dispatch-later [{:ms 1000 :dispatch [:chat.ui/navigate-to-chat chat-id]}]}
|
|
||||||
(navigation/pop-to-root-tab :chat-stack))))
|
|
||||||
|
|
||||||
(fx/defn handle-chat-removed
|
(fx/defn handle-chat-removed
|
||||||
{:events [:chat-removed]}
|
{:events [:chat-removed]}
|
||||||
|
|
|
@ -14,19 +14,13 @@
|
||||||
[status-im.utils.fx :as fx]
|
[status-im.utils.fx :as fx]
|
||||||
[status-im.utils.platform :as platform]
|
[status-im.utils.platform :as platform]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[status-im.multiaccounts.login.core :as login-core]))
|
[status-im.multiaccounts.login.core :as login-core]
|
||||||
|
[status-im.navigation.state :as state]))
|
||||||
|
|
||||||
(def debug? ^boolean js/goog.DEBUG)
|
(def debug? ^boolean js/goog.DEBUG)
|
||||||
|
|
||||||
(def splash-screen (-> rn .-NativeModules .-SplashScreen))
|
(def splash-screen (-> rn .-NativeModules .-SplashScreen))
|
||||||
|
|
||||||
(defonce root-comp-id (atom nil))
|
|
||||||
(defonce root-id (atom nil))
|
|
||||||
(defonce pushed-screen-id (atom nil))
|
|
||||||
(defonce curr-modal (atom nil))
|
|
||||||
(defonce modals (atom []))
|
|
||||||
(defonce dissmissing (atom false))
|
|
||||||
|
|
||||||
(defonce set-navigation-default-options
|
(defonce set-navigation-default-options
|
||||||
(.setDefaultOptions Navigation (clj->js {:layout {:orientation "portrait"}})))
|
(.setDefaultOptions Navigation (clj->js {:layout {:orientation "portrait"}})))
|
||||||
|
|
||||||
|
@ -43,19 +37,19 @@
|
||||||
|
|
||||||
(defn dismiss-all-modals []
|
(defn dismiss-all-modals []
|
||||||
(log/debug "dissmiss-all-modals")
|
(log/debug "dissmiss-all-modals")
|
||||||
(when @curr-modal
|
(when @state/curr-modal
|
||||||
(reset! curr-modal false)
|
(reset! state/curr-modal false)
|
||||||
(reset! dissmissing true)
|
(reset! state/dissmissing true)
|
||||||
(doseq [modal @modals]
|
(doseq [modal @state/modals]
|
||||||
(.dismissModal Navigation (name modal)))
|
(.dismissModal Navigation (name modal)))
|
||||||
(reset! modals [])))
|
(reset! state/modals [])))
|
||||||
|
|
||||||
;; PUSH SCREEN
|
;; PUSH SCREEN
|
||||||
(defn navigate [comp]
|
(defn navigate [comp]
|
||||||
(log/debug "NAVIGATE" comp)
|
(log/debug "NAVIGATE" comp)
|
||||||
(let [{:keys [options]} (get views/screens comp)]
|
(let [{:keys [options]} (get views/screens comp)]
|
||||||
(.push Navigation
|
(.push Navigation
|
||||||
(name @root-comp-id)
|
(name @state/root-comp-id)
|
||||||
(clj->js {:component {:id comp
|
(clj->js {:component {:id comp
|
||||||
:name comp
|
:name comp
|
||||||
:options (merge options
|
:options (merge options
|
||||||
|
@ -80,11 +74,11 @@
|
||||||
(defn open-modal [comp]
|
(defn open-modal [comp]
|
||||||
(log/debug "open-modal" comp)
|
(log/debug "open-modal" comp)
|
||||||
(let [{:keys [options]} (get views/screens comp)]
|
(let [{:keys [options]} (get views/screens comp)]
|
||||||
(if @dissmissing
|
(if @state/dissmissing
|
||||||
(reset! dissmissing comp)
|
(reset! state/dissmissing comp)
|
||||||
(do
|
(do
|
||||||
(reset! curr-modal true)
|
(reset! state/curr-modal true)
|
||||||
(swap! modals conj comp)
|
(swap! state/modals conj comp)
|
||||||
(.showModal Navigation
|
(.showModal Navigation
|
||||||
(clj->js {:stack {:children
|
(clj->js {:stack {:children
|
||||||
[{:component
|
[{:component
|
||||||
|
@ -100,8 +94,8 @@
|
||||||
;; DISSMISS MODAL
|
;; DISSMISS MODAL
|
||||||
(defn dissmissModal []
|
(defn dissmissModal []
|
||||||
(log/debug "dissmissModal")
|
(log/debug "dissmissModal")
|
||||||
(reset! dissmissing true)
|
(reset! state/dissmissing true)
|
||||||
(.dismissModal Navigation (name (last @modals))))
|
(.dismissModal Navigation (name (last @state/modals))))
|
||||||
|
|
||||||
(defonce register-nav-button-reg
|
(defonce register-nav-button-reg
|
||||||
(.registerNavigationButtonPressedListener
|
(.registerNavigationButtonPressedListener
|
||||||
|
@ -110,7 +104,7 @@
|
||||||
(let [id (.-buttonId evn)]
|
(let [id (.-buttonId evn)]
|
||||||
(if (= "dismiss-modal" id)
|
(if (= "dismiss-modal" id)
|
||||||
(do
|
(do
|
||||||
(when-let [event (get-in views/screens [(last @modals) :on-dissmiss])]
|
(when-let [event (get-in views/screens [(last @state/modals) :on-dissmiss])]
|
||||||
(re-frame/dispatch event))
|
(re-frame/dispatch event))
|
||||||
(dissmissModal))
|
(dissmissModal))
|
||||||
(when-let [handler (get-in views/screens [(keyword id) :right-handler])]
|
(when-let [handler (get-in views/screens [(keyword id) :right-handler])]
|
||||||
|
@ -128,17 +122,17 @@
|
||||||
(.registerModalDismissedListener
|
(.registerModalDismissedListener
|
||||||
(.events Navigation)
|
(.events Navigation)
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(if (> (count @modals) 1)
|
(if (> (count @state/modals) 1)
|
||||||
(let [new-modals (butlast @modals)]
|
(let [new-modals (butlast @state/modals)]
|
||||||
(reset! modals (vec new-modals))
|
(reset! state/modals (vec new-modals))
|
||||||
(set-view-id (last new-modals)))
|
(set-view-id (last new-modals)))
|
||||||
(do
|
(do
|
||||||
(reset! modals [])
|
(reset! state/modals [])
|
||||||
(reset! curr-modal false)
|
(reset! state/curr-modal false)
|
||||||
(set-view-id @pushed-screen-id)))
|
(set-view-id @state/pushed-screen-id)))
|
||||||
|
|
||||||
(let [comp @dissmissing]
|
(let [comp @state/dissmissing]
|
||||||
(reset! dissmissing false)
|
(reset! state/dissmissing false)
|
||||||
(when (keyword? comp)
|
(when (keyword? comp)
|
||||||
(open-modal comp))))))
|
(open-modal comp))))))
|
||||||
|
|
||||||
|
@ -154,8 +148,8 @@
|
||||||
(not= view-id :popover)
|
(not= view-id :popover)
|
||||||
(not= view-id :visibility-status-popover))
|
(not= view-id :visibility-status-popover))
|
||||||
(set-view-id view-id)
|
(set-view-id view-id)
|
||||||
(when-not @curr-modal
|
(when-not @state/curr-modal
|
||||||
(reset! pushed-screen-id view-id))))))))
|
(reset! state/pushed-screen-id view-id))))))))
|
||||||
|
|
||||||
;; SCREEN DID DISAPPEAR
|
;; SCREEN DID DISAPPEAR
|
||||||
(defonce screen-disappear-reg
|
(defonce screen-disappear-reg
|
||||||
|
@ -176,16 +170,16 @@
|
||||||
:init-root-fx
|
:init-root-fx
|
||||||
(fn [new-root-id]
|
(fn [new-root-id]
|
||||||
(log/debug :init-root-fx new-root-id)
|
(log/debug :init-root-fx new-root-id)
|
||||||
(reset! root-comp-id new-root-id)
|
(reset! state/root-comp-id new-root-id)
|
||||||
(reset! root-id @root-comp-id)
|
(reset! state/root-id @state/root-comp-id)
|
||||||
(.setRoot Navigation (clj->js (get (roots/roots) new-root-id)))))
|
(.setRoot Navigation (clj->js (get (roots/roots) new-root-id)))))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:init-root-with-component-fx
|
:init-root-with-component-fx
|
||||||
(fn [[new-root-id new-root-comp-id]]
|
(fn [[new-root-id new-root-comp-id]]
|
||||||
(log/debug :init-root-with-component-fx new-root-id new-root-comp-id)
|
(log/debug :init-root-with-component-fx new-root-id new-root-comp-id)
|
||||||
(reset! root-comp-id new-root-comp-id)
|
(reset! state/root-comp-id new-root-comp-id)
|
||||||
(reset! root-id @root-comp-id)
|
(reset! state/root-id @state/root-comp-id)
|
||||||
(.setRoot Navigation (clj->js (get (roots/roots) new-root-id)))))
|
(.setRoot Navigation (clj->js (get (roots/roots) new-root-id)))))
|
||||||
|
|
||||||
(fx/defn set-multiaccount-root
|
(fx/defn set-multiaccount-root
|
||||||
|
@ -201,13 +195,14 @@
|
||||||
(defonce rset-app-launched
|
(defonce rset-app-launched
|
||||||
(.registerAppLaunchedListener (.events Navigation)
|
(.registerAppLaunchedListener (.events Navigation)
|
||||||
(fn []
|
(fn []
|
||||||
(reset! curr-modal false)
|
(reset! state/curr-modal false)
|
||||||
(reset! dissmissing false)
|
(reset! state/dissmissing false)
|
||||||
(if (or (= @root-id :multiaccounts) (= @root-id :multiaccounts-keycard))
|
(if (or (= @state/root-id :multiaccounts)
|
||||||
|
(= @state/root-id :multiaccounts-keycard))
|
||||||
(re-frame/dispatch-sync [::set-multiaccount-root])
|
(re-frame/dispatch-sync [::set-multiaccount-root])
|
||||||
(when @root-id
|
(when @state/root-id
|
||||||
(reset! root-comp-id @root-id)
|
(reset! state/root-comp-id @state/root-id)
|
||||||
(.setRoot Navigation (clj->js (get (roots/roots) @root-id)))
|
(.setRoot Navigation (clj->js (get (roots/roots) @state/root-id)))
|
||||||
(re-frame/dispatch [::login-core/check-last-chat])))
|
(re-frame/dispatch [::login-core/check-last-chat])))
|
||||||
(.hide ^js splash-screen))))
|
(.hide ^js splash-screen))))
|
||||||
|
|
||||||
|
@ -248,7 +243,7 @@
|
||||||
:change-tab-fx
|
:change-tab-fx
|
||||||
(fn [tab]
|
(fn [tab]
|
||||||
(log/debug :change-tab-fx)
|
(log/debug :change-tab-fx)
|
||||||
(reset! root-comp-id (get tab-root-ids (get tab-key-idx tab)))
|
(reset! state/root-comp-id (get tab-root-ids (get tab-key-idx tab)))
|
||||||
(.mergeOptions Navigation "tabs-stack" (clj->js {:bottomTabs {:currentTabIndex (get tab-key-idx tab)}}))
|
(.mergeOptions Navigation "tabs-stack" (clj->js {:bottomTabs {:currentTabIndex (get tab-key-idx tab)}}))
|
||||||
;;when we change tab we want to dismiss all modals
|
;;when we change tab we want to dismiss all modals
|
||||||
(dismiss-all-modals)))
|
(dismiss-all-modals)))
|
||||||
|
@ -289,9 +284,9 @@
|
||||||
comp (get tab-root-ids selected-tab-index)
|
comp (get tab-root-ids selected-tab-index)
|
||||||
tab-key (get (clojure.set/map-invert tab-key-idx) selected-tab-index)]
|
tab-key (get (clojure.set/map-invert tab-key-idx) selected-tab-index)]
|
||||||
(re-frame/dispatch [:set :current-tab tab-key])
|
(re-frame/dispatch [:set :current-tab tab-key])
|
||||||
(when (and platform/android? (= @root-comp-id comp))
|
(when (and platform/android? (= @state/root-comp-id comp))
|
||||||
(.popToRoot Navigation (name comp)))
|
(.popToRoot Navigation (name comp)))
|
||||||
(reset! root-comp-id comp)))))
|
(reset! state/root-comp-id comp)))))
|
||||||
|
|
||||||
;; OVERLAY (Popover and bottom sheets)
|
;; OVERLAY (Popover and bottom sheets)
|
||||||
(defn dissmiss-overlay [comp]
|
(defn dissmiss-overlay [comp]
|
||||||
|
@ -405,15 +400,15 @@
|
||||||
:navigate-back-fx
|
:navigate-back-fx
|
||||||
(fn []
|
(fn []
|
||||||
(log/debug :navigate-back-fx)
|
(log/debug :navigate-back-fx)
|
||||||
(if @curr-modal
|
(if @state/curr-modal
|
||||||
(dissmissModal)
|
(dissmissModal)
|
||||||
(.pop Navigation (name @root-comp-id)))))
|
(.pop Navigation (name @state/root-comp-id)))))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:navigate-replace-fx
|
:navigate-replace-fx
|
||||||
(fn [view-id]
|
(fn [view-id]
|
||||||
(log/debug :navigate-replace-fx view-id)
|
(log/debug :navigate-replace-fx view-id)
|
||||||
(.pop Navigation (name @root-comp-id))
|
(.pop Navigation (name @state/root-comp-id))
|
||||||
(navigate view-id)))
|
(navigate view-id)))
|
||||||
|
|
||||||
(def community-screens '(:community-management
|
(def community-screens '(:community-management
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
(ns status-im.navigation.state)
|
||||||
|
|
||||||
|
(defonce root-comp-id (atom nil))
|
||||||
|
(defonce root-id (atom nil))
|
||||||
|
(defonce pushed-screen-id (atom nil))
|
||||||
|
(defonce curr-modal (atom nil))
|
||||||
|
(defonce modals (atom []))
|
||||||
|
(defonce dissmissing (atom false))
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
(fx/defn handle-public-chat [cofx {:keys [topic]}]
|
(fx/defn handle-public-chat [cofx {:keys [topic]}]
|
||||||
(when (seq topic)
|
(when (seq topic)
|
||||||
(chat/start-public-chat cofx topic {})))
|
(chat/start-public-chat cofx topic)))
|
||||||
|
|
||||||
(fx/defn handle-group-chat [cofx params]
|
(fx/defn handle-group-chat [cofx params]
|
||||||
(group-chats/create-from-link cofx params))
|
(group-chats/create-from-link cofx params))
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
[status-im.utils.platform :as platform]
|
[status-im.utils.platform :as platform]
|
||||||
[status-im.utils.utils :as utils]
|
[status-im.utils.utils :as utils]
|
||||||
["react" :as reactjs]
|
["react" :as reactjs]
|
||||||
["react-native" :as react-native :refer (Keyboard)]
|
["react-native" :as react-native :refer (Keyboard BackHandler)]
|
||||||
["react-native-image-crop-picker" :default image-picker]
|
["react-native-image-crop-picker" :default image-picker]
|
||||||
["react-native-safe-area-context" :as safe-area-context
|
["react-native-safe-area-context" :as safe-area-context
|
||||||
:refer (SafeAreaProvider SafeAreaInsetsContext)]
|
:refer (SafeAreaProvider SafeAreaInsetsContext)]
|
||||||
|
@ -270,3 +270,9 @@
|
||||||
|
|
||||||
(def safe-area-provider (reagent/adapt-react-class SafeAreaProvider))
|
(def safe-area-provider (reagent/adapt-react-class SafeAreaProvider))
|
||||||
(def safe-area-consumer (reagent/adapt-react-class (.-Consumer ^js SafeAreaInsetsContext)))
|
(def safe-area-consumer (reagent/adapt-react-class (.-Consumer ^js SafeAreaInsetsContext)))
|
||||||
|
|
||||||
|
(defn hw-back-add-listener [callback]
|
||||||
|
(.addEventListener BackHandler "hardwareBackPress" callback))
|
||||||
|
|
||||||
|
(defn hw-back-remove-listener [callback]
|
||||||
|
(.removeEventListener BackHandler "hardwareBackPress" callback))
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
(:require-macros [status-im.utils.views :as views]))
|
(:require-macros [status-im.utils.views :as views]))
|
||||||
|
|
||||||
(defn- start-chat [topic]
|
(defn- start-chat [topic]
|
||||||
(re-frame/dispatch [:chat.ui/start-public-chat topic {:navigation-reset? true}])
|
(re-frame/dispatch [:chat.ui/start-public-chat topic])
|
||||||
(re-frame/dispatch [:set :public-group-topic nil]))
|
(re-frame/dispatch [:set :public-group-topic nil]))
|
||||||
|
|
||||||
(defn- hash-icon []
|
(defn- hash-icon []
|
||||||
|
|
|
@ -86,10 +86,7 @@
|
||||||
:accessibility-label :open-chat
|
:accessibility-label :open-chat
|
||||||
:title (str "#" topic)
|
:title (str "#" topic)
|
||||||
:subtitle (i18n/label :t/open-chat)
|
:subtitle (i18n/label :t/open-chat)
|
||||||
:on-press #(do
|
:on-press #(hide-sheet-and-dispatch [:chat.ui/start-public-chat topic])
|
||||||
(re-frame/dispatch [:navigate-change-tab :chat])
|
|
||||||
(re-frame/dispatch [:pop-to-root-tab :chat-stack])
|
|
||||||
(hide-sheet-and-dispatch [:chat.ui/start-public-chat topic {:navigation-reset? true}]))
|
|
||||||
:chevron true}]
|
:chevron true}]
|
||||||
[components/separator]])
|
[components/separator]])
|
||||||
(if connected?
|
(if connected?
|
||||||
|
|
|
@ -159,7 +159,7 @@
|
||||||
:text-decoration-line :underline}
|
:text-decoration-line :underline}
|
||||||
:on-press
|
:on-press
|
||||||
#(re-frame/dispatch
|
#(re-frame/dispatch
|
||||||
[:chat.ui/start-public-chat literal {:navigation-reset? true}])}
|
[:chat.ui/start-public-chat literal])}
|
||||||
"#"
|
"#"
|
||||||
literal])
|
literal])
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
(ns status-im.ui.screens.chat.views
|
(ns status-im.ui.screens.chat.views
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
|
re-frame.db
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[status-im.i18n.i18n :as i18n]
|
[status-im.i18n.i18n :as i18n]
|
||||||
[status-im.ui.components.chat-icon.screen :as chat-icon.screen]
|
[status-im.ui.components.chat-icon.screen :as chat-icon.screen]
|
||||||
|
@ -32,7 +33,9 @@
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.utils.platform :as platform]
|
[status-im.utils.platform :as platform]
|
||||||
[status-im.utils.utils :as utils]
|
[status-im.utils.utils :as utils]
|
||||||
[status-im.ui.screens.chat.sheets :as sheets]))
|
[status-im.ui.screens.chat.sheets :as sheets]
|
||||||
|
[status-im.utils.debounce :as debounce]
|
||||||
|
[status-im.navigation.state :as navigation.state]))
|
||||||
|
|
||||||
(defn invitation-requests [chat-id admins]
|
(defn invitation-requests [chat-id admins]
|
||||||
(let [current-pk @(re-frame/subscribe [:multiaccount/public-key])
|
(let [current-pk @(re-frame/subscribe [:multiaccount/public-key])
|
||||||
|
@ -332,20 +335,41 @@
|
||||||
:inverted (when platform/ios? true)
|
:inverted (when platform/ios? true)
|
||||||
:style (when platform/android? {:scaleY -1})})]))
|
:style (when platform/android? {:scaleY -1})})]))
|
||||||
|
|
||||||
(defn topbar-button []
|
(defn topbar-content []
|
||||||
(re-frame/dispatch [:bottom-sheet/show-sheet
|
|
||||||
{:content (fn []
|
|
||||||
[sheets/current-chat-actions])
|
|
||||||
:height 256}]))
|
|
||||||
|
|
||||||
(defn topbar []
|
|
||||||
(let [window-width @(re-frame/subscribe [:dimensions/window-width])
|
(let [window-width @(re-frame/subscribe [:dimensions/window-width])
|
||||||
{:keys [group-chat chat-id] :as chat-info} @(re-frame/subscribe [:chats/current-chat])]
|
{:keys [group-chat chat-id] :as chat-info} @(re-frame/subscribe [:chats/current-chat])]
|
||||||
[react/touchable-highlight {:on-press #(when-not group-chat (re-frame/dispatch [:chat.ui/show-profile chat-id]))
|
[react/touchable-highlight {:on-press #(when-not group-chat
|
||||||
:style {:flex 1 :width (- window-width 120)}}
|
(debounce/dispatch-and-chill [:chat.ui/show-profile chat-id] 1000))
|
||||||
|
:style {:flex 1 :width (- window-width 120)}}
|
||||||
[toolbar-content/toolbar-content-view-inner chat-info]]))
|
[toolbar-content/toolbar-content-view-inner chat-info]]))
|
||||||
|
|
||||||
(defn chat []
|
(defn navigate-back-handler []
|
||||||
|
(when (and (not @navigation.state/curr-modal) (= (get @re-frame.db/app-db :view-id) :chat))
|
||||||
|
(react/hw-back-remove-listener navigate-back-handler)
|
||||||
|
(re-frame/dispatch [:close-chat])
|
||||||
|
(re-frame/dispatch [:navigate-back])))
|
||||||
|
|
||||||
|
(defn topbar []
|
||||||
|
;;we don't use topbar component, because we want chat view as simple (fast) as possible
|
||||||
|
[react/view {:height 56}
|
||||||
|
[react/touchable-highlight {:on-press-in navigate-back-handler
|
||||||
|
:accessibility-label :back-button
|
||||||
|
:style {:height 56 :width 40 :align-items :center :justify-content :center
|
||||||
|
:padding-left 16}}
|
||||||
|
[icons/icon :main-icons/arrow-left {:color colors/black}]]
|
||||||
|
[react/view {:flex 1 :left 52 :right 52 :top 0 :bottom 0 :position :absolute}
|
||||||
|
[topbar-content]]
|
||||||
|
[react/touchable-highlight {:on-press-in #(re-frame/dispatch [:bottom-sheet/show-sheet
|
||||||
|
{:content (fn []
|
||||||
|
[sheets/current-chat-actions])
|
||||||
|
:height 256}])
|
||||||
|
:accessibility-label :chat-menu-button
|
||||||
|
:style {:right 0 :top 0 :bottom 0 :position :absolute
|
||||||
|
:height 56 :width 40 :align-items :center :justify-content :center
|
||||||
|
:padding-right 16}}
|
||||||
|
[icons/icon :main-icons/more {:color colors/black}]]])
|
||||||
|
|
||||||
|
(defn chat-render []
|
||||||
(let [bottom-space (reagent/atom 0)
|
(let [bottom-space (reagent/atom 0)
|
||||||
panel-space (reagent/atom 52)
|
panel-space (reagent/atom 52)
|
||||||
active-panel (reagent/atom nil)
|
active-panel (reagent/atom nil)
|
||||||
|
@ -363,6 +387,7 @@
|
||||||
@(re-frame/subscribe [:chats/current-chat-chat-view])
|
@(re-frame/subscribe [:chats/current-chat-chat-view])
|
||||||
max-bottom-space (max @bottom-space @panel-space)]
|
max-bottom-space (max @bottom-space @panel-space)]
|
||||||
[:<>
|
[:<>
|
||||||
|
[topbar]
|
||||||
[connectivity/loading-indicator]
|
[connectivity/loading-indicator]
|
||||||
(when chat-id
|
(when chat-id
|
||||||
(if group-chat
|
(if group-chat
|
||||||
|
@ -398,3 +423,11 @@
|
||||||
:set-active-panel set-active-panel
|
:set-active-panel set-active-panel
|
||||||
:text-input-ref text-input-ref}]]
|
:text-input-ref text-input-ref}]]
|
||||||
[bottom-sheet @active-panel]])]))))
|
[bottom-sheet @active-panel]])]))))
|
||||||
|
|
||||||
|
(defn chat []
|
||||||
|
(reagent/create-class
|
||||||
|
{:component-did-mount (fn []
|
||||||
|
(react/hw-back-remove-listener navigate-back-handler)
|
||||||
|
(react/hw-back-add-listener navigate-back-handler))
|
||||||
|
:component-will-unmount (fn [] (react/hw-back-remove-listener navigate-back-handler))
|
||||||
|
:reagent-render chat-render}))
|
||||||
|
|
|
@ -31,8 +31,7 @@
|
||||||
:accessibility-label :request-a-feature-button
|
:accessibility-label :request-a-feature-button
|
||||||
:on-press
|
:on-press
|
||||||
#(re-frame/dispatch [:chat.ui/start-public-chat
|
#(re-frame/dispatch [:chat.ui/start-public-chat
|
||||||
"support"
|
"support"])
|
||||||
{:navigation-reset? false}])
|
|
||||||
:chevron true}])
|
:chevron true}])
|
||||||
|
|
||||||
(defn help-center []
|
(defn help-center []
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
[status-im.ui.components.plus-button :as components.plus-button]
|
[status-im.ui.components.plus-button :as components.plus-button]
|
||||||
[status-im.ui.screens.chat.sheets :as sheets]
|
[status-im.ui.screens.chat.sheets :as sheets]
|
||||||
[status-im.ui.components.tabbar.core :as tabbar]
|
[status-im.ui.components.tabbar.core :as tabbar]
|
||||||
["react-native-navigation" :refer (Navigation)]
|
|
||||||
[status-im.ui.components.invite.views :as invite]
|
[status-im.ui.components.invite.views :as invite]
|
||||||
[status-im.utils.config :as config])
|
[status-im.utils.config :as config])
|
||||||
(:require-macros [status-im.utils.views :as views]))
|
(:require-macros [status-im.utils.views :as views]))
|
||||||
|
@ -180,19 +179,13 @@
|
||||||
:accessibility-label :notifications-unread-badge}]])]))
|
:accessibility-label :notifications-unread-badge}]])]))
|
||||||
|
|
||||||
(defn home []
|
(defn home []
|
||||||
(reagent/create-class
|
[react/keyboard-avoiding-view {:style {:flex 1}
|
||||||
{:component-did-mount #(set! (.-navigationEventListener %) (.bindComponent (.events Navigation) % "home"))
|
:ignore-offset true}
|
||||||
:componentWillAppear #(do (re-frame/dispatch-sync [:set :view-id :home])
|
[topbar/topbar {:title (i18n/label :t/chat)
|
||||||
(re-frame/dispatch [:close-chat]))
|
:navigation :none
|
||||||
:reagent-render
|
:right-component [react/view {:flex-direction :row :margin-right 16}
|
||||||
(fn []
|
[connectivity/connectivity-button]
|
||||||
[react/keyboard-avoiding-view {:style {:flex 1}
|
[notifications-button]]}]
|
||||||
:ignore-offset true}
|
[chats-list]
|
||||||
[topbar/topbar {:title (i18n/label :t/chat)
|
[plus-button]
|
||||||
:navigation :none
|
[tabbar/tabs-counts-subscriptions]])
|
||||||
:right-component [react/view {:flex-direction :row :margin-right 16}
|
|
||||||
[connectivity/connectivity-button]
|
|
||||||
[notifications-button]]}]
|
|
||||||
[chats-list]
|
|
||||||
[plus-button]
|
|
||||||
[tabbar/tabs-counts-subscriptions]])}))
|
|
||||||
|
|
|
@ -123,8 +123,7 @@
|
||||||
;[quo2.foundations.colors :as quo2.colors]))
|
;[quo2.foundations.colors :as quo2.colors]))
|
||||||
|
|
||||||
(def components
|
(def components
|
||||||
[{:name :chat-toolbar
|
[])
|
||||||
:component chat/topbar}])
|
|
||||||
|
|
||||||
(defn right-button-options [id icon]
|
(defn right-button-options [id icon]
|
||||||
{:id id
|
{:id id
|
||||||
|
@ -222,10 +221,9 @@
|
||||||
;Chat
|
;Chat
|
||||||
{:name :chat
|
{:name :chat
|
||||||
:options {:popGesture false
|
:options {:popGesture false
|
||||||
:topBar {:title {:component {:name :chat-toolbar :id :chat-toolbar}
|
:hardwareBackButton {:dismissModalOnPress false
|
||||||
:alignment :fill}
|
:popStackOnPress false}
|
||||||
:rightButtons (right-button-options :chat :more)}}
|
:topBar {:visible false}}
|
||||||
:right-handler chat/topbar-button
|
|
||||||
:component chat/chat}
|
:component chat/chat}
|
||||||
|
|
||||||
;Pinned messages
|
;Pinned messages
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
(fx/defn handle-public-chat [cofx {:keys [topic]}]
|
(fx/defn handle-public-chat [cofx {:keys [topic]}]
|
||||||
(log/info "universal-links: handling public chat" topic)
|
(log/info "universal-links: handling public chat" topic)
|
||||||
(when (seq topic)
|
(when (seq topic)
|
||||||
(chat/start-public-chat cofx topic {})))
|
(chat/start-public-chat cofx topic)))
|
||||||
|
|
||||||
(fx/defn handle-view-profile
|
(fx/defn handle-view-profile
|
||||||
[{:keys [db] :as cofx} {:keys [public-key ens-name]}]
|
[{:keys [db] :as cofx} {:keys [public-key ens-name]}]
|
||||||
|
|
|
@ -15,7 +15,7 @@ from views.base_element import Button, BaseElement, EditBox, Text, CheckBox
|
||||||
|
|
||||||
class BackButton(Button):
|
class BackButton(Button):
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
super().__init__(driver, accessibility_id="Navigate Up")
|
super().__init__(driver, accessibility_id="back-button")
|
||||||
|
|
||||||
def click(self, times_to_click: int = 1):
|
def click(self, times_to_click: int = 1):
|
||||||
for _ in range(times_to_click):
|
for _ in range(times_to_click):
|
||||||
|
|
Loading…
Reference in New Issue