Skip to content

Commit

Permalink
improve profile screen performance
Browse files Browse the repository at this point in the history
  • Loading branch information
flexsurfer committed Dec 22, 2023
1 parent 5eb0baa commit 99cb41a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
12 changes: 7 additions & 5 deletions src/quo/components/settings/category/settings/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
:size :paragraph-2
:style (style/label props)}
label])
[rn/flat-list
{:data data
:style (style/settings-items props)
:render-fn settings-item/view
:separator [rn/view {:style (style/settings-separator props)}]}]])
[rn/view {:style (style/settings-items props)}
(for [item data]
^{:key item}
[:<>
[settings-item/view item]
(when-not (= item (last data))
[rn/view {:style (style/settings-separator props)}])])]])

(def settings-category (quo.theme/with-theme category-internal))
23 changes: 11 additions & 12 deletions src/status_im/contexts/profile/settings/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

(defn- settings-item-view
[data]
[quo/category
{:list-type :settings
:container-style {:padding-bottom 0}
:blur? true
:data data}])
[rf/delay-render
[quo/category
{:list-type :settings
:container-style {:padding-bottom 0}
:blur? true
:data data}]])

(defn scroll-handler
[event scroll-y]
Expand All @@ -29,12 +30,13 @@

(defn- footer
[logout-press]
[rn/view {:style style/footer-container}
[quo/logout-button {:on-press logout-press}]])
[rf/delay-render
[rn/view {:style style/footer-container}
[quo/logout-button {:on-press logout-press}]]])

(defn- get-item-layout
[_ index]
#js {:length 48 :offset (* 48 index) :index index})
#js {:length 100 :offset (* 100 index) :index index})

(defn- settings-view
[theme]
Expand All @@ -60,12 +62,9 @@
{:key :list
:header [settings.header/view {:scroll-y scroll-y}]
:data settings.items/items
:key-fn :title
:get-item-layout get-item-layout
:initial-num-to-render 6
:max-to-render-per-batch 6
:shows-vertical-scroll-indicator false
:render-fn settings-item-view
:get-item-layout get-item-layout
:footer [footer logout-press]
:scroll-event-throttle 16
:on-scroll #(scroll-handler % scroll-y)
Expand Down
9 changes: 9 additions & 0 deletions src/utils/re_frame.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
(:require
[re-frame.core :as re-frame]
[re-frame.interceptor :as interceptor]
[reagent.core :as reagent]
[taoensso.timbre :as log]
[utils.datetime :as datetime])
(:refer-clojure :exclude [merge reduce]))
Expand Down Expand Up @@ -76,6 +77,14 @@
(swap! handler-nesting-level dec)
res))

(defn delay-render
[content]
(let [render? (reagent/atom false)]
(js/setTimeout #(reset! render? true) 0)
(fn []
(when @render?
content))))

(def sub (comp deref re-frame/subscribe))

(def dispatch re-frame/dispatch)
Expand Down

0 comments on commit 99cb41a

Please sign in to comment.