use community subs correctly for performance
This commit is contained in:
parent
731ccdf2e5
commit
b353dc6f1f
|
@ -69,9 +69,8 @@
|
||||||
[{:keys [notification set-swipeable-height customization-color] :as props}]
|
[{:keys [notification set-swipeable-height customization-color] :as props}]
|
||||||
(let [{:keys [author community-id id membership-status
|
(let [{:keys [author community-id id membership-status
|
||||||
read timestamp]} notification
|
read timestamp]} notification
|
||||||
community (rf/sub [:communities/community community-id])
|
community-name (rf/sub [:communities/name community-id])
|
||||||
community-name (:name community)
|
community-logo (rf/sub [:communities/logo community-id])]
|
||||||
community-image (get-in community [:images :thumbnail :uri])]
|
|
||||||
[swipeable props
|
[swipeable props
|
||||||
[quo/activity-log
|
[quo/activity-log
|
||||||
{:title (i18n/label :t/join-request)
|
{:title (i18n/label :t/join-request)
|
||||||
|
@ -86,7 +85,7 @@
|
||||||
{:type :community
|
{:type :community
|
||||||
:size 24
|
:size 24
|
||||||
:blur? true
|
:blur? true
|
||||||
:community-logo community-image
|
:community-logo community-logo
|
||||||
:community-name community-name}]]
|
:community-name community-name}]]
|
||||||
:items (condp = membership-status
|
:items (condp = membership-status
|
||||||
constants/activity-center-membership-status-accepted
|
constants/activity-center-membership-status-accepted
|
||||||
|
|
|
@ -23,16 +23,13 @@
|
||||||
child])
|
child])
|
||||||
|
|
||||||
(defn- get-header-text-and-context
|
(defn- get-header-text-and-context
|
||||||
[community membership-status]
|
[community-logo community-name community-permissions membership-status]
|
||||||
(let [community-name (:name community)
|
(let [open? (not= 3 (:access community-permissions))
|
||||||
permissions (:permissions community)
|
|
||||||
open? (not= 3 (:access permissions))
|
|
||||||
community-image (get-in community [:images :thumbnail :uri])
|
|
||||||
community-context-tag [quo/context-tag
|
community-context-tag [quo/context-tag
|
||||||
{:type :community
|
{:type :community
|
||||||
:size 24
|
:size 24
|
||||||
:blur? true
|
:blur? true
|
||||||
:community-logo community-image
|
:community-logo community-logo
|
||||||
:community-name community-name}]]
|
:community-name community-name}]]
|
||||||
(cond
|
(cond
|
||||||
(= membership-status constants/activity-center-membership-status-idle)
|
(= membership-status constants/activity-center-membership-status-idle)
|
||||||
|
@ -63,16 +60,21 @@
|
||||||
(defn view
|
(defn view
|
||||||
[{:keys [notification set-swipeable-height customization-color] :as props}]
|
[{:keys [notification set-swipeable-height customization-color] :as props}]
|
||||||
(let [{:keys [community-id membership-status read
|
(let [{:keys [community-id membership-status read
|
||||||
timestamp]} notification
|
timestamp]} notification
|
||||||
community (rf/sub [:communities/community community-id])
|
community-name (rf/sub [:communities/name community-id])
|
||||||
|
community-logo (rf/sub [:communities/logo community-id])
|
||||||
|
community-permissions (rf/sub [:communities/permissions community-id])
|
||||||
{:keys [header-text
|
{:keys [header-text
|
||||||
context]} (get-header-text-and-context community
|
context]} (get-header-text-and-context community-logo
|
||||||
membership-status)
|
community-name
|
||||||
on-press (rn/use-callback
|
community-permissions
|
||||||
(fn []
|
membership-status)
|
||||||
(rf/dispatch [:navigate-back])
|
on-press (rn/use-callback
|
||||||
(rf/dispatch [:communities/navigate-to-community-overview community-id]))
|
(fn []
|
||||||
[community-id])]
|
(rf/dispatch [:navigate-back])
|
||||||
|
(rf/dispatch [:communities/navigate-to-community-overview
|
||||||
|
community-id]))
|
||||||
|
[community-id])]
|
||||||
[swipeable props
|
[swipeable props
|
||||||
[gesture/touchable-without-feedback {:on-press on-press}
|
[gesture/touchable-without-feedback {:on-press on-press}
|
||||||
[quo/activity-log
|
[quo/activity-log
|
||||||
|
|
|
@ -46,9 +46,8 @@
|
||||||
(let [{:keys [author chat-name community-id chat-id
|
(let [{:keys [author chat-name community-id chat-id
|
||||||
message read timestamp]} notification
|
message read timestamp]} notification
|
||||||
community-chat? (not (string/blank? community-id))
|
community-chat? (not (string/blank? community-id))
|
||||||
community (rf/sub [:communities/community community-id])
|
community-name (rf/sub [:communities/name community-id])
|
||||||
community-name (:name community)
|
community-logo (rf/sub [:communities/logo community-id])]
|
||||||
community-image (get-in community [:images :thumbnail :uri])]
|
|
||||||
[swipeable props
|
[swipeable props
|
||||||
[gesture/touchable-without-feedback
|
[gesture/touchable-without-feedback
|
||||||
{:on-press (fn []
|
{:on-press (fn []
|
||||||
|
@ -69,7 +68,7 @@
|
||||||
{:type :channel
|
{:type :channel
|
||||||
:blur? true
|
:blur? true
|
||||||
:size 24
|
:size 24
|
||||||
:community-logo community-image
|
:community-logo community-logo
|
||||||
:community-name community-name
|
:community-name community-name
|
||||||
:channel-name chat-name}]
|
:channel-name chat-name}]
|
||||||
[quo/context-tag
|
[quo/context-tag
|
||||||
|
|
|
@ -68,9 +68,8 @@
|
||||||
message read timestamp
|
message read timestamp
|
||||||
album-messages]} notification
|
album-messages]} notification
|
||||||
community-chat? (not (string/blank? community-id))
|
community-chat? (not (string/blank? community-id))
|
||||||
community (rf/sub [:communities/community community-id])
|
community-name (rf/sub [:communities/name community-id])
|
||||||
community-name (:name community)
|
community-logo (rf/sub [:communities/logo community-id])
|
||||||
community-image (get-in community [:images :thumbnail :uri])
|
|
||||||
media-server-port (rf/sub [:mediaserver/port])]
|
media-server-port (rf/sub [:mediaserver/port])]
|
||||||
[swipeable props
|
[swipeable props
|
||||||
[gesture/touchable-without-feedback
|
[gesture/touchable-without-feedback
|
||||||
|
@ -91,7 +90,7 @@
|
||||||
{:type :channel
|
{:type :channel
|
||||||
:blur? true
|
:blur? true
|
||||||
:size 24
|
:size 24
|
||||||
:community-logo community-image
|
:community-logo community-logo
|
||||||
:community-name community-name
|
:community-name community-name
|
||||||
:channel-name chat-name}]
|
:channel-name chat-name}]
|
||||||
[quo/context-tag
|
[quo/context-tag
|
||||||
|
|
|
@ -15,12 +15,33 @@
|
||||||
(fn [info [_ id]]
|
(fn [info [_ id]]
|
||||||
(get info id)))
|
(get info id)))
|
||||||
|
|
||||||
|
;; Do not use this subscription directly in views. There is a significant risk
|
||||||
|
;; of re-rendering views too frequently because an active community can change
|
||||||
|
;; for numerous reasons.
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:communities/community
|
:communities/community
|
||||||
:<- [:communities]
|
:<- [:communities]
|
||||||
(fn [communities [_ id]]
|
(fn [communities [_ id]]
|
||||||
(get communities id)))
|
(get communities id)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub :communities/logo
|
||||||
|
(fn [[_ community-id]]
|
||||||
|
[(re-frame/subscribe [:communities/community community-id])])
|
||||||
|
(fn [[community]]
|
||||||
|
(get-in community [:images :thumbnail :uri])))
|
||||||
|
|
||||||
|
(re-frame/reg-sub :communities/name
|
||||||
|
(fn [[_ community-id]]
|
||||||
|
[(re-frame/subscribe [:communities/community community-id])])
|
||||||
|
(fn [[{:keys [name]}]]
|
||||||
|
name))
|
||||||
|
|
||||||
|
(re-frame/reg-sub :communities/permissions
|
||||||
|
(fn [[_ community-id]]
|
||||||
|
[(re-frame/subscribe [:communities/community community-id])])
|
||||||
|
(fn [[{:keys [permissions]}]]
|
||||||
|
permissions))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:communities/community-color
|
:communities/community-color
|
||||||
(fn [[_ community-id]]
|
(fn [[_ community-id]]
|
||||||
|
|
Loading…
Reference in New Issue