diff --git a/src/status_im/ui/screens/discover/components/views.cljs b/src/status_im/ui/screens/discover/components/views.cljs index f5c7957030..8ba66a53ce 100644 --- a/src/status_im/ui/screens/discover/components/views.cljs +++ b/src/status_im/ui/screens/discover/components/views.cljs @@ -48,63 +48,63 @@ [react/text {:style styles/chat-button-text :uppercase? (:uppercase? styles/chat-button-text-case)} (i18n/label :t/chat)]]]]) -(defview discover-list-item [{:keys [message show-separator? current-account]}] - (letsubs [{contact-name :name - contact-photo-path :photo-path} [:get-in [:contacts/contacts (:whisper-id message)]]] - (let [{:keys [name photo-path whisper-id message-id status]} message - {account-photo-path :photo-path - account-address :public-key - account-name :name} current-account - me? (= account-address whisper-id)] - [react/view - [react/view styles/discover-list-item - [view/status-view {:id message-id - :style styles/discover-item-status-text - :status status}] - [react/view styles/discover-list-item-second-row - [react/view styles/discover-list-item-name-container - [react/view styles/discover-list-item-avatar-container - [chat-icon/chat-icon - (display-image me? account-photo-path contact-photo-path photo-path whisper-id) - {:size 24}]] - [react/text {:style styles/discover-list-item-name - :font :medium - :number-of-lines 1} - (display-name me? account-name contact-name name whisper-id)]] +(defn discover-list-item [{:keys [message show-separator? current-account contacts]}] + (let [{contact-name :name + contact-photo-path :photo-path} (get contacts (:whisper-id message)) + {:keys [name photo-path whisper-id message-id status]} message + {account-photo-path :photo-path + account-address :public-key + account-name :name} current-account + me? (= account-address whisper-id)] + [react/view + [react/view styles/discover-list-item + [view/status-view {:id message-id + :style styles/discover-item-status-text + :status status}] + [react/view styles/discover-list-item-second-row + [react/view styles/discover-list-item-name-container + [react/view styles/discover-list-item-avatar-container + [chat-icon/chat-icon + (display-image me? account-photo-path contact-photo-path photo-path whisper-id) + {:size 24}]] + [react/text {:style styles/discover-list-item-name + :font :medium + :number-of-lines 1} + (display-name me? account-name contact-name name whisper-id)]] - (when-not me? - (chat-button whisper-id))] - (when show-separator? - [react/view styles/separator])]]))) + (when-not me? + (chat-button whisper-id))] + (when show-separator? + [react/view styles/separator])]])) ;; NOTE(oskarth): Should possibly be merged with discover-list-item-full, but ;; there are too many differences between preview item (main screen) and full ;; screen, so safer to modify custom styles here without risking regressions. -(defview discover-list-item-full [{:keys [message show-separator? current-account]}] - (letsubs [{contact-name :name - contact-photo-path :photo-path} [:get-in [:contacts/contacts (:whisper-id message)]]] - (let [{:keys [name photo-path whisper-id message-id status]} message - {account-photo-path :photo-path - account-address :public-key - account-name :name} current-account - me? (= account-address whisper-id)] - [react/view - [react/view styles/discover-list-item-full ;; XXX: Custom style here - [view/status-view {:id message-id - :style styles/discover-item-status-text - :status status}] - [react/view styles/discover-list-item-second-row - [react/view styles/discover-list-item-name-container - [react/view styles/discover-list-item-avatar-container - [chat-icon/chat-icon - (display-image me? account-photo-path contact-photo-path photo-path whisper-id) - {:size 24}]] - [react/text {:style styles/discover-list-item-name - :font :medium - :number-of-lines 1} - (display-name me? account-name contact-name name whisper-id)]] +(defn discover-list-item-full [{:keys [message show-separator? current-account contacts]}] + (let [{contact-name :name + contact-photo-path :photo-path} (get contacts (:whisper-id message)) + {:keys [name photo-path whisper-id message-id status]} message + {account-photo-path :photo-path + account-address :public-key + account-name :name} current-account + me? (= account-address whisper-id)] + [react/view + [react/view styles/discover-list-item-full ;; XXX: Custom style here + [view/status-view {:id message-id + :style styles/discover-item-status-text + :status status}] + [react/view styles/discover-list-item-second-row + [react/view styles/discover-list-item-name-container + [react/view styles/discover-list-item-avatar-container + [chat-icon/chat-icon + (display-image me? account-photo-path contact-photo-path photo-path whisper-id) + {:size 24}]] + [react/text {:style styles/discover-list-item-name + :font :medium + :number-of-lines 1} + (display-name me? account-name contact-name name whisper-id)]] - (when-not me? - (chat-button whisper-id))]] - (when show-separator? - [react/view styles/separator])]))) + (when-not me? + (chat-button whisper-id))]] + (when show-separator? + [react/view styles/separator])])) diff --git a/src/status_im/ui/screens/discover/popular_hashtags/views.cljs b/src/status_im/ui/screens/discover/popular_hashtags/views.cljs index e188af7a2b..f4533266df 100644 --- a/src/status_im/ui/screens/discover/popular_hashtags/views.cljs +++ b/src/status_im/ui/screens/discover/popular_hashtags/views.cljs @@ -27,6 +27,7 @@ (defview discover-all-hashtags [] (letsubs [current-account [:get-current-account] popular-tags [:get-popular-tags 10] + contacts [:get-contacts] {:keys [discoveries]} [:get-popular-discoveries 10]] ;uses the tags passed via :discover-search-tags state [react/view styles/all-recent-container [toolbar/toolbar2 {} @@ -42,4 +43,5 @@ [components/discover-list-item-full {:message message :show-separator? (not= (inc i) (count discoveries)) + :contacts contacts :current-account current-account}]))]]]])) diff --git a/src/status_im/ui/screens/discover/recent_statuses/views.cljs b/src/status_im/ui/screens/discover/recent_statuses/views.cljs index 5670623ef4..c541fbb857 100644 --- a/src/status_im/ui/screens/discover/recent_statuses/views.cljs +++ b/src/status_im/ui/screens/discover/recent_statuses/views.cljs @@ -9,7 +9,8 @@ (defview discover-all-recent [] (letsubs [discoveries [:get-recent-discoveries] tabs-hidden? [:tabs-hidden?] - current-account [:get-current-account]] + current-account [:get-current-account] + contacts [:get-contacts]] [react/view styles/all-recent-container [toolbar/toolbar2 {} toolbar/default-nav-back @@ -24,4 +25,5 @@ [components/discover-list-item-full {:message message :show-separator? (not= (inc i) (count discoveries)) + :contacts contacts :current-account current-account}]))]]])])) diff --git a/src/status_im/ui/screens/discover/search_results/views.cljs b/src/status_im/ui/screens/discover/search_results/views.cljs index 71aef89d3b..f812743357 100644 --- a/src/status_im/ui/screens/discover/search_results/views.cljs +++ b/src/status_im/ui/screens/discover/search_results/views.cljs @@ -19,6 +19,7 @@ (defview discover-search-results [] (letsubs [{:keys [discoveries total]} [:get-popular-discoveries 250] tags [:get :discover-search-tags] + contacts [:get-contacts] current-account [:get-current-account]] (let [datasource (to-datasource discoveries)] [react/view styles/discover-tag-container @@ -39,6 +40,7 @@ :renderRow (fn [row _ _] (react/list-item [components/discover-list-item {:message row - :current-account current-account}])) + :current-account current-account + :contacts contacts}])) :renderSeparator render-separator :style styles/status-list-inner}])]))) diff --git a/src/status_im/ui/screens/discover/views.cljs b/src/status_im/ui/screens/discover/views.cljs index a3aae56ec4..7cf73b8373 100644 --- a/src/status_im/ui/screens/discover/views.cljs +++ b/src/status_im/ui/screens/discover/views.cljs @@ -47,7 +47,7 @@ (re-frame/dispatch [:navigate-to :discover-search-results]))))}]) -(defview top-status-for-popular-hashtag [{:keys [tag current-account]}] +(defview top-status-for-popular-hashtag [{:keys [tag current-account contacts]}] (letsubs [discoveries [:get-popular-discoveries 1 [tag]]] [react/view styles/popular-list-container [react/view styles/row @@ -65,7 +65,8 @@ (str (:total discoveries))]]] [components/discover-list-item {:message (first (:discoveries discoveries)) :show-separator? false - :current-account current-account}]])) + :current-account current-account + :contacts contacts}]])) (defview popular-hashtags-preview [{:keys [contacts current-account]}] (letsubs [popular-tags [:get-popular-tags 10]] @@ -85,7 +86,7 @@ :current-account current-account}])] [empty-section :empty-hashtags :t/no-hashtags-discovered-title :t/no-hashtags-discovered-body])]))) -(defn recent-statuses-preview [current-account discoveries] +(defn recent-statuses-preview [{:keys [current-account contacts discoveries]}] (let [has-content? (seq discoveries)] [react/view styles/recent-statuses-preview-container [components/title :t/recent :t/all #(re-frame/dispatch [:navigate-to :discover-all-recent]) has-content?] @@ -98,7 +99,8 @@ [react/view styles/recent-statuses-preview-content [components/discover-list-item {:message discovery :show-separator? false - :current-account current-account}]])] + :current-account current-account + :contacts contacts}]])] [empty-section :empty-recent :t/no-statuses-discovered :t/no-statuses-discovered-body])])) (def public-chats-mock-data @@ -147,7 +149,9 @@ [toolbar-view (and current-view? (= show-search :discover)) search-text] [react/scroll-view styles/list-container - [recent-statuses-preview current-account discoveries] + [recent-statuses-preview {:contacts contacts + :current-account current-account + :discoveries discoveries}] [popular-hashtags-preview {:contacts contacts :current-account current-account}] [all-dapps/preview all-dapps]