Use stable handlers (except for chat renderer)
This commit is contained in:
@@ -45,21 +45,35 @@
|
||||
:description (i18n/label :t/no-messages-description)
|
||||
:image (resources/get-themed-image :cat-in-box theme)}})
|
||||
|
||||
(defn on-end-reached
|
||||
[]
|
||||
(re-frame/dispatch [:chat/show-more-chats]))
|
||||
|
||||
(defn chat-key-fn
|
||||
[chat]
|
||||
(or (:chat-id chat) (:public-key chat) (:id chat)))
|
||||
|
||||
(defn chats
|
||||
[{:keys [theme selected-tab set-scroll-ref scroll-shared-value]}]
|
||||
(let [unfiltered-items (rf/sub [:chats/chats-stack-items])
|
||||
items (filter-and-sort-items-by-tab selected-tab unfiltered-items)]
|
||||
items (filter-and-sort-items-by-tab selected-tab unfiltered-items)
|
||||
on-scroll (rn/use-callback
|
||||
(fn [event]
|
||||
(common.banner/set-scroll-shared-value
|
||||
{:scroll-input (oops/oget event
|
||||
"nativeEvent.contentOffset.y")
|
||||
:shared-value scroll-shared-value})))]
|
||||
(if (empty? items)
|
||||
[common.empty-state/view
|
||||
{:selected-tab selected-tab
|
||||
:tab->content (empty-state-content theme)}]
|
||||
[reanimated/flat-list
|
||||
{:ref set-scroll-ref
|
||||
:key-fn #(or (:chat-id %) (:public-key %) (:id %))
|
||||
:key-fn chat-key-fn
|
||||
:content-inset-adjustment-behavior :never
|
||||
:header [common.header-spacing/view]
|
||||
:get-item-layout get-item-layout
|
||||
:on-end-reached #(re-frame/dispatch [:chat/show-more-chats])
|
||||
:on-end-reached on-end-reached
|
||||
:keyboard-should-persist-taps :always
|
||||
:data items
|
||||
:render-fn (fn [item]
|
||||
@@ -68,9 +82,7 @@
|
||||
:content-container-style {:padding-bottom
|
||||
shell.constants/floating-shell-button-height
|
||||
:padding-top 8}
|
||||
:on-scroll #(common.banner/set-scroll-shared-value
|
||||
{:scroll-input (oops/oget % "nativeEvent.contentOffset.y")
|
||||
:shared-value scroll-shared-value})}])))
|
||||
:on-scroll on-scroll}])))
|
||||
|
||||
(defn contact-item-render
|
||||
[{:keys [public-key] :as item} theme]
|
||||
|
||||
Reference in New Issue
Block a user