|
72 | 72 |
|
73 | 73 | (re-frame/reg-sub
|
74 | 74 | :communities/featured-communities
|
75 |
| - :<- [:search/home-filter] |
76 | 75 | :<- [:communities]
|
77 |
| - (fn [[search-filter communities]] |
78 |
| - (filterv |
79 |
| - (fn [{:keys [name]}] |
80 |
| - (or (empty? search-filter) |
81 |
| - (string/includes? (string/lower-case (str name)) search-filter))) |
82 |
| - (vals communities)))) |
| 76 | + (fn [communities] |
| 77 | + (vals communities))) |
83 | 78 |
|
84 | 79 | (re-frame/reg-sub
|
85 | 80 | :communities/sorted-communities
|
86 | 81 | :<- [:communities]
|
87 | 82 | (fn [communities]
|
88 | 83 | (sort-by :name (vals communities))))
|
89 | 84 |
|
90 |
| -(re-frame/reg-sub |
91 |
| - :communities/communities |
92 |
| - :<- [:search/home-filter] |
93 |
| - :<- [:communities] |
94 |
| - (fn [[search-filter communities]] |
95 |
| - (filterv |
96 |
| - (fn [{:keys [name]}] |
97 |
| - (or (empty? search-filter) |
98 |
| - (string/includes? (string/lower-case (str name)) search-filter))) |
99 |
| - (vals communities)))) |
100 |
| - |
101 | 85 | (re-frame/reg-sub
|
102 | 86 | :communities/community-ids
|
103 |
| - :<- [:communities/communities] |
| 87 | + :<- [:communities] |
104 | 88 | (fn [communities]
|
105 |
| - (map :id communities))) |
| 89 | + (map :id (vals communities)))) |
| 90 | + |
| 91 | +(def memo-communities-stack-items (atom nil)) |
106 | 92 |
|
107 | 93 | (re-frame/reg-sub
|
108 | 94 | :communities/grouped-by-status
|
109 |
| - :<- [:communities/communities] |
| 95 | + :<- [:view-id] |
| 96 | + :<- [:communities] |
110 | 97 | :<- [:communities/my-pending-requests-to-join]
|
111 | 98 | ;; Return communities splitted by level of user participation. Some communities user
|
112 | 99 | ;; already joined, to some of them join request sent and others were opened one day
|
113 | 100 | ;; and their data remained in app-db.
|
114 | 101 | ;; Result map has form: {:joined [id1, id2] :pending [id3, id5] :opened [id4]}"
|
115 |
| - (fn [[communities requests]] |
116 |
| - (reduce (fn [acc community] |
117 |
| - (let [joined? (:joined community) |
118 |
| - community-id (:id community) |
119 |
| - pending? (boolean (get requests community-id))] |
120 |
| - (cond |
121 |
| - joined? (update acc :joined conj community) |
122 |
| - pending? (update acc :pending conj community) |
123 |
| - :else (update acc :opened conj community)))) |
124 |
| - {:joined [] :pending [] :opened []} |
125 |
| - communities))) |
| 102 | + (fn [[view-id communities requests]] |
| 103 | + (if (= view-id :communities-stack) |
| 104 | + (let [grouped-communities (reduce (fn [acc community] |
| 105 | + (let [joined? (:joined community) |
| 106 | + community-id (:id community) |
| 107 | + pending? (boolean (get requests community-id))] |
| 108 | + (cond |
| 109 | + joined? (update acc :joined conj community) |
| 110 | + pending? (update acc :pending conj community) |
| 111 | + :else (update acc :opened conj community)))) |
| 112 | + {:joined [] :pending [] :opened []} |
| 113 | + (vals communities))] |
| 114 | + (reset! memo-communities-stack-items grouped-communities) |
| 115 | + grouped-communities) |
| 116 | + @memo-communities-stack-items))) |
126 | 117 |
|
127 | 118 | (defn community->home-item
|
128 | 119 | [community counts]
|
|
0 commit comments