Aliases in discovery (#477)
This commit is contained in:
parent
3efb8a7bb8
commit
e0313ef9c6
|
@ -61,7 +61,7 @@
|
||||||
:font :medium}
|
:font :medium}
|
||||||
(label label-kw)]])
|
(label label-kw)]])
|
||||||
|
|
||||||
(defview discovery-popular [{:keys [contacts]}]
|
(defview discovery-popular [{:keys [contacts current-account]}]
|
||||||
[popular-tags [:get-popular-tags 10]]
|
[popular-tags [:get-popular-tags 10]]
|
||||||
[view st/popular-container
|
[view st/popular-container
|
||||||
[title :t/popular-tags false]
|
[title :t/popular-tags false]
|
||||||
|
@ -71,30 +71,35 @@
|
||||||
:sneak (if (> (count popular-tags) 1) 16 8)}
|
:sneak (if (> (count popular-tags) 1) 16 8)}
|
||||||
(for [{:keys [name]} popular-tags]
|
(for [{:keys [name]} popular-tags]
|
||||||
[discovery-popular-list {:tag name
|
[discovery-popular-list {:tag name
|
||||||
:contacts contacts}])]
|
:contacts contacts
|
||||||
|
:current-account current-account}])]
|
||||||
[text (label :t/none)])])
|
[text (label :t/none)])])
|
||||||
|
|
||||||
(defview discovery-recent [{:keys [contacts]}]
|
(defview discovery-recent [{:keys [current-account]}]
|
||||||
[discoveries [:get-recent-discoveries]]
|
[discoveries [:get-recent-discoveries]]
|
||||||
(when (seq discoveries)
|
(when (seq discoveries)
|
||||||
[view st/recent-container
|
[view st/recent-container
|
||||||
[title :t/recent true]
|
[title :t/recent true]
|
||||||
[view st/recent-list
|
[view st/recent-list
|
||||||
(let [discoveries (map-indexed vector discoveries)]
|
(let [discoveries (map-indexed vector discoveries)]
|
||||||
(for [[i {:keys [message-id] :as discovery}] discoveries]
|
(for [[i {:keys [message-id] :as message}] discoveries]
|
||||||
^{:key (str "message-" message-id)}
|
^{:key (str "message-" message-id)}
|
||||||
[discovery-list-item discovery (not= (inc i) (count discoveries))]))]]))
|
[discovery-list-item {:message message
|
||||||
|
:show-separator? (not= (inc i) (count discoveries))
|
||||||
|
:current-account current-account}]))]]))
|
||||||
|
|
||||||
(defview discovery []
|
(defview discovery []
|
||||||
[show-search? [:get ::show-search?]
|
[show-search? [:get ::show-search?]
|
||||||
contacts [:get :contacts]
|
contacts [:get :contacts]
|
||||||
|
current-account [:get-current-account]
|
||||||
discoveries [:get-recent-discoveries]]
|
discoveries [:get-recent-discoveries]]
|
||||||
[view st/discovery-container
|
[view st/discovery-container
|
||||||
[discovery-toolbar show-search?]
|
[discovery-toolbar show-search?]
|
||||||
(if discoveries
|
(if discoveries
|
||||||
[scroll-view st/scroll-view-container
|
[scroll-view st/scroll-view-container
|
||||||
[discovery-popular {:contacts contacts}]
|
[discovery-popular {:contacts contacts
|
||||||
[discovery-recent {:contacts contacts}]]
|
:current-account current-account}]
|
||||||
|
[discovery-recent {:current-account current-account}]]
|
||||||
[view contacts-styles/empty-contact-groups
|
[view contacts-styles/empty-contact-groups
|
||||||
;; todo change icon
|
;; todo change icon
|
||||||
[icon :group_big contacts-styles/empty-contacts-icon]
|
[icon :group_big contacts-styles/empty-contacts-icon]
|
||||||
|
|
|
@ -37,7 +37,8 @@
|
||||||
|
|
||||||
(defview discovery-search-results []
|
(defview discovery-search-results []
|
||||||
[discoveries [:get-popular-discoveries 250]
|
[discoveries [:get-popular-discoveries 250]
|
||||||
tags [:get :discovery-search-tags]]
|
tags [:get :discovery-search-tags]
|
||||||
|
current-account [:get-current-account]]
|
||||||
(let [discoveries (:discoveries discoveries)
|
(let [discoveries (:discoveries discoveries)
|
||||||
datasource (to-datasource discoveries)]
|
datasource (to-datasource discoveries)]
|
||||||
[view st/discovery-tag-container
|
[view st/discovery-tag-container
|
||||||
|
@ -55,6 +56,7 @@
|
||||||
(label :t/no-statuses-found)]]
|
(label :t/no-statuses-found)]]
|
||||||
[list-view {:dataSource datasource
|
[list-view {:dataSource datasource
|
||||||
:renderRow (fn [row _ _]
|
:renderRow (fn [row _ _]
|
||||||
(list-item [discovery-list-item row]))
|
(list-item [discovery-list-item {:message row
|
||||||
|
:current-account current-account}]))
|
||||||
:renderSeparator render-separator
|
:renderSeparator render-separator
|
||||||
:style st/recent-list}])]))
|
:style st/recent-list}])]))
|
||||||
|
|
|
@ -26,8 +26,15 @@
|
||||||
^{:key (str "item-" message-id "-" i)}
|
^{:key (str "item-" message-id "-" i)}
|
||||||
(str status " ")))])
|
(str status " ")))])
|
||||||
|
|
||||||
(defview discovery-list-item [{:keys [name photo-path whisper-id] :as message}
|
(defview discovery-list-item [{{:keys [name
|
||||||
show-separator?]
|
photo-path
|
||||||
|
whisper-id]
|
||||||
|
:as message} :message
|
||||||
|
show-separator? :show-separator?
|
||||||
|
{account-photo-path :photo-path
|
||||||
|
account-address :public-key
|
||||||
|
account-name :name
|
||||||
|
:as current-account} :current-account}]
|
||||||
[{contact-name :name
|
[{contact-name :name
|
||||||
contact-photo-path :photo-path} [:get-in [:contacts whisper-id]]]
|
contact-photo-path :photo-path} [:get-in [:contacts whisper-id]]]
|
||||||
(let [item-style (get-in platform-specific [:component-styles :discovery :item])]
|
(let [item-style (get-in platform-specific [:component-styles :discovery :item])]
|
||||||
|
@ -38,6 +45,7 @@
|
||||||
:font :medium
|
:font :medium
|
||||||
:number-of-lines 1}
|
:number-of-lines 1}
|
||||||
(cond
|
(cond
|
||||||
|
(= account-address whisper-id) account-name
|
||||||
(not (str/blank? contact-name)) contact-name
|
(not (str/blank? contact-name)) contact-name
|
||||||
(not (str/blank? name)) name
|
(not (str/blank? name)) name
|
||||||
:else (generate-gfy))]
|
:else (generate-gfy))]
|
||||||
|
@ -47,6 +55,7 @@
|
||||||
[touchable-highlight {:on-press #(dispatch [:start-chat whisper-id])}
|
[touchable-highlight {:on-press #(dispatch [:start-chat whisper-id])}
|
||||||
[view
|
[view
|
||||||
[ci/chat-icon (cond
|
[ci/chat-icon (cond
|
||||||
|
(= account-address whisper-id) account-photo-path
|
||||||
(not (str/blank? contact-photo-path)) contact-photo-path
|
(not (str/blank? contact-photo-path)) contact-photo-path
|
||||||
(not (str/blank? photo-path)) photo-path
|
(not (str/blank? photo-path)) photo-path
|
||||||
:else (identicon whisper-id))
|
:else (identicon whisper-id))
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
[status-im.discovery.views.discovery-list-item :refer [discovery-list-item]]
|
[status-im.discovery.views.discovery-list-item :refer [discovery-list-item]]
|
||||||
[status-im.utils.platform :refer [platform-specific]]))
|
[status-im.utils.platform :refer [platform-specific]]))
|
||||||
|
|
||||||
(defview discovery-popular-list [{:keys [tag contacts]}]
|
(defview discovery-popular-list [{:keys [tag contacts current-account]}]
|
||||||
[discoveries [:get-popular-discoveries 3 [tag]]]
|
[discoveries [:get-popular-discoveries 3 [tag]]]
|
||||||
[view (merge st/popular-list-container
|
[view (merge st/popular-list-container
|
||||||
(get-in platform-specific [:component-styles :discovery :popular]))
|
(get-in platform-specific [:component-styles :discovery :popular]))
|
||||||
|
@ -31,4 +31,6 @@
|
||||||
(let [discoveries (map-indexed vector (:discoveries discoveries))]
|
(let [discoveries (map-indexed vector (:discoveries discoveries))]
|
||||||
(for [[i {:keys [message-id] :as discovery}] discoveries]
|
(for [[i {:keys [message-id] :as discovery}] discoveries]
|
||||||
^{:key (str "message-" message-id)}
|
^{:key (str "message-" message-id)}
|
||||||
[discovery-list-item discovery (not= (inc i) (count discoveries))]))])
|
[discovery-list-item {:message discovery
|
||||||
|
:show-separator? (not= (inc i) (count discoveries))
|
||||||
|
:current-account current-account}]))])
|
||||||
|
|
Loading…
Reference in New Issue