small chat perf impr
Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
693c41850c
commit
448782b3d3
|
@ -274,7 +274,8 @@
|
||||||
[{db :db :as cofx} chat-id]
|
[{db :db :as cofx} chat-id]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
(close-chat)
|
(close-chat)
|
||||||
#(assoc-in % [:db :current-chat-id] chat-id)
|
(fn [{:keys [db]}]
|
||||||
|
{:db (assoc db :current-chat-id chat-id)})
|
||||||
(preload-chat-data chat-id)
|
(preload-chat-data chat-id)
|
||||||
(navigation/navigate-to-cofx :chat-stack {:screen :chat})))
|
(navigation/navigate-to-cofx :chat-stack {:screen :chat})))
|
||||||
|
|
||||||
|
|
|
@ -966,13 +966,12 @@
|
||||||
:chats/chat-messages-stream
|
:chats/chat-messages-stream
|
||||||
(fn [[_ chat-id] _]
|
(fn [[_ chat-id] _]
|
||||||
[(re-frame/subscribe [:chats/raw-chat-messages-stream chat-id])
|
[(re-frame/subscribe [:chats/raw-chat-messages-stream chat-id])
|
||||||
|
(re-frame/subscribe [:chats/chat-no-messages? chat-id])
|
||||||
(re-frame/subscribe [:view-id])])
|
(re-frame/subscribe [:view-id])])
|
||||||
(fn [[messages view-id]]
|
(fn [[messages empty view-id]]
|
||||||
(if (or (= view-id :chat) (empty? messages))
|
(when (or (= view-id :chat) empty)
|
||||||
(do
|
(reset! memo-chat-messages-stream messages))
|
||||||
(reset! memo-chat-messages-stream messages)
|
@memo-chat-messages-stream))
|
||||||
messages)
|
|
||||||
@memo-chat-messages-stream)))
|
|
||||||
|
|
||||||
(def memo-profile-messages-stream (atom nil))
|
(def memo-profile-messages-stream (atom nil))
|
||||||
|
|
||||||
|
@ -980,13 +979,12 @@
|
||||||
:chats/profile-messages-stream
|
:chats/profile-messages-stream
|
||||||
(fn [[_ chat-id] _]
|
(fn [[_ chat-id] _]
|
||||||
[(re-frame/subscribe [:chats/raw-chat-messages-stream chat-id])
|
[(re-frame/subscribe [:chats/raw-chat-messages-stream chat-id])
|
||||||
|
(re-frame/subscribe [:chats/chat-no-messages? chat-id])
|
||||||
(re-frame/subscribe [:view-id])])
|
(re-frame/subscribe [:view-id])])
|
||||||
(fn [[messages view-id]]
|
(fn [[messages empty view-id]]
|
||||||
(if (or (= view-id :profile) (empty? messages))
|
(when (or (= view-id :profile) empty)
|
||||||
(do
|
(reset! memo-profile-messages-stream messages))
|
||||||
(reset! memo-profile-messages-stream messages)
|
@memo-profile-messages-stream))
|
||||||
messages)
|
|
||||||
@memo-profile-messages-stream)))
|
|
||||||
|
|
||||||
(def memo-timeline-messages-stream (atom nil))
|
(def memo-timeline-messages-stream (atom nil))
|
||||||
|
|
||||||
|
|
|
@ -164,6 +164,9 @@
|
||||||
(defn chat-list-key-fn [item]
|
(defn chat-list-key-fn [item]
|
||||||
(or (:chat-id item) (:id item)))
|
(or (:chat-id item) (:id item)))
|
||||||
|
|
||||||
|
(defn get-item-layout [_ index]
|
||||||
|
#js {:length 64 :offset (* 64 index) :index index})
|
||||||
|
|
||||||
(views/defview communities-and-chats []
|
(views/defview communities-and-chats []
|
||||||
(views/letsubs [{:keys [items search-filter]} [:home-items]
|
(views/letsubs [{:keys [items search-filter]} [:home-items]
|
||||||
hide-home-tooltip? [:hide-home-tooltip?]]
|
hide-home-tooltip? [:hide-home-tooltip?]]
|
||||||
|
@ -174,6 +177,7 @@
|
||||||
[welcome-blank-page]
|
[welcome-blank-page]
|
||||||
[list/flat-list
|
[list/flat-list
|
||||||
{:key-fn chat-list-key-fn
|
{:key-fn chat-list-key-fn
|
||||||
|
:getItemLayout get-item-layout
|
||||||
:initialNumToRender 5
|
:initialNumToRender 5
|
||||||
:keyboard-should-persist-taps :always
|
:keyboard-should-persist-taps :always
|
||||||
:data items
|
:data items
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
[status-im.utils.contenthash :as contenthash]
|
[status-im.utils.contenthash :as contenthash]
|
||||||
[status-im.utils.core :as utils]
|
[status-im.utils.core :as utils]
|
||||||
[status-im.utils.datetime :as time]
|
[status-im.utils.datetime :as time]
|
||||||
[status-im.ui.components.chat-icon.styles :as chat-icon.styles]
|
[status-im.ui.components.chat-icon.styles :as chat-icon.styles]))
|
||||||
[status-im.ui.screens.chat.sheets :as sheets]))
|
|
||||||
|
|
||||||
(defn mention-element [from]
|
(defn mention-element [from]
|
||||||
@(re-frame/subscribe [:contacts/contact-name-by-identity from]))
|
@(re-frame/subscribe [:contacts/contact-name-by-identity from]))
|
||||||
|
@ -124,21 +123,6 @@
|
||||||
:accessibility-label :unviewed-messages-public}]
|
:accessibility-label :unviewed-messages-public}]
|
||||||
[badge/message-counter unviewed-messages-count])]))
|
[badge/message-counter unviewed-messages-count])]))
|
||||||
|
|
||||||
(def memo-on-long-press
|
|
||||||
(memoize
|
|
||||||
(fn [chat-id]
|
|
||||||
(fn []
|
|
||||||
(re-frame/dispatch [:bottom-sheet/show-sheet
|
|
||||||
{:content (fn [] [sheets/chat-actions chat-id])}])))))
|
|
||||||
|
|
||||||
(def memo-on-press
|
|
||||||
(memoize
|
|
||||||
(fn [chat-id]
|
|
||||||
(fn []
|
|
||||||
(re-frame/dispatch [:dismiss-keyboard])
|
|
||||||
(re-frame/dispatch [:chat.ui/navigate-to-chat chat-id])
|
|
||||||
(re-frame/dispatch [:search/home-filter-changed nil])))))
|
|
||||||
|
|
||||||
(defn icon-style []
|
(defn icon-style []
|
||||||
{:color colors/black
|
{:color colors/black
|
||||||
:width 15
|
:width 15
|
||||||
|
|
Loading…
Reference in New Issue