diff --git a/src/status_im/contexts/chat/home/view.cljs b/src/status_im/contexts/chat/home/view.cljs index 7cfa873d71..ca9647a6d7 100644 --- a/src/status_im/contexts/chat/home/view.cljs +++ b/src/status_im/contexts/chat/home/view.cljs @@ -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]