small chat perf impr

Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
andrey 2021-04-27 11:48:41 +02:00
parent 693c41850c
commit 448782b3d3
No known key found for this signature in database
GPG Key ID: 89B67245FD2F0272
4 changed files with 17 additions and 30 deletions

View File

@ -274,7 +274,8 @@
[{db :db :as cofx} chat-id]
(fx/merge cofx
(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)
(navigation/navigate-to-cofx :chat-stack {:screen :chat})))

View File

@ -966,13 +966,12 @@
:chats/chat-messages-stream
(fn [[_ 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])])
(fn [[messages view-id]]
(if (or (= view-id :chat) (empty? messages))
(do
(reset! memo-chat-messages-stream messages)
messages)
@memo-chat-messages-stream)))
(fn [[messages empty view-id]]
(when (or (= view-id :chat) empty)
(reset! memo-chat-messages-stream messages))
@memo-chat-messages-stream))
(def memo-profile-messages-stream (atom nil))
@ -980,13 +979,12 @@
:chats/profile-messages-stream
(fn [[_ 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])])
(fn [[messages view-id]]
(if (or (= view-id :profile) (empty? messages))
(do
(reset! memo-profile-messages-stream messages)
messages)
@memo-profile-messages-stream)))
(fn [[messages empty view-id]]
(when (or (= view-id :profile) empty)
(reset! memo-profile-messages-stream messages))
@memo-profile-messages-stream))
(def memo-timeline-messages-stream (atom nil))

View File

@ -164,6 +164,9 @@
(defn chat-list-key-fn [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/letsubs [{:keys [items search-filter]} [:home-items]
hide-home-tooltip? [:hide-home-tooltip?]]
@ -174,6 +177,7 @@
[welcome-blank-page]
[list/flat-list
{:key-fn chat-list-key-fn
:getItemLayout get-item-layout
:initialNumToRender 5
:keyboard-should-persist-taps :always
:data items

View File

@ -13,8 +13,7 @@
[status-im.utils.contenthash :as contenthash]
[status-im.utils.core :as utils]
[status-im.utils.datetime :as time]
[status-im.ui.components.chat-icon.styles :as chat-icon.styles]
[status-im.ui.screens.chat.sheets :as sheets]))
[status-im.ui.components.chat-icon.styles :as chat-icon.styles]))
(defn mention-element [from]
@(re-frame/subscribe [:contacts/contact-name-by-identity from]))
@ -124,21 +123,6 @@
:accessibility-label :unviewed-messages-public}]
[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 []
{:color colors/black
:width 15