bug #2270 - wrong username in received discoveries

This commit is contained in:
Goran Jovic 2017-10-23 13:52:01 +02:00 committed by Roman Volosovskyi
parent 0ccfefa6c3
commit 7bbd6cc6c6
5 changed files with 71 additions and 61 deletions

View File

@ -48,10 +48,10 @@
[react/text {:style styles/chat-button-text [react/text {:style styles/chat-button-text
:uppercase? (:uppercase? styles/chat-button-text-case)} (i18n/label :t/chat)]]]]) :uppercase? (:uppercase? styles/chat-button-text-case)} (i18n/label :t/chat)]]]])
(defview discover-list-item [{:keys [message show-separator? current-account]}] (defn discover-list-item [{:keys [message show-separator? current-account contacts]}]
(letsubs [{contact-name :name (let [{contact-name :name
contact-photo-path :photo-path} [:get-in [:contacts/contacts (:whisper-id message)]]] contact-photo-path :photo-path} (get contacts (:whisper-id message))
(let [{:keys [name photo-path whisper-id message-id status]} message {:keys [name photo-path whisper-id message-id status]} message
{account-photo-path :photo-path {account-photo-path :photo-path
account-address :public-key account-address :public-key
account-name :name} current-account account-name :name} current-account
@ -75,15 +75,15 @@
(when-not me? (when-not me?
(chat-button whisper-id))] (chat-button whisper-id))]
(when show-separator? (when show-separator?
[react/view styles/separator])]]))) [react/view styles/separator])]]))
;; NOTE(oskarth): Should possibly be merged with discover-list-item-full, but ;; NOTE(oskarth): Should possibly be merged with discover-list-item-full, but
;; there are too many differences between preview item (main screen) and full ;; there are too many differences between preview item (main screen) and full
;; screen, so safer to modify custom styles here without risking regressions. ;; screen, so safer to modify custom styles here without risking regressions.
(defview discover-list-item-full [{:keys [message show-separator? current-account]}] (defn discover-list-item-full [{:keys [message show-separator? current-account contacts]}]
(letsubs [{contact-name :name (let [{contact-name :name
contact-photo-path :photo-path} [:get-in [:contacts/contacts (:whisper-id message)]]] contact-photo-path :photo-path} (get contacts (:whisper-id message))
(let [{:keys [name photo-path whisper-id message-id status]} message {:keys [name photo-path whisper-id message-id status]} message
{account-photo-path :photo-path {account-photo-path :photo-path
account-address :public-key account-address :public-key
account-name :name} current-account account-name :name} current-account
@ -107,4 +107,4 @@
(when-not me? (when-not me?
(chat-button whisper-id))]] (chat-button whisper-id))]]
(when show-separator? (when show-separator?
[react/view styles/separator])]))) [react/view styles/separator])]))

View File

@ -27,6 +27,7 @@
(defview discover-all-hashtags [] (defview discover-all-hashtags []
(letsubs [current-account [:get-current-account] (letsubs [current-account [:get-current-account]
popular-tags [:get-popular-tags 10] popular-tags [:get-popular-tags 10]
contacts [:get-contacts]
{:keys [discoveries]} [:get-popular-discoveries 10]] ;uses the tags passed via :discover-search-tags state {:keys [discoveries]} [:get-popular-discoveries 10]] ;uses the tags passed via :discover-search-tags state
[react/view styles/all-recent-container [react/view styles/all-recent-container
[toolbar/toolbar2 {} [toolbar/toolbar2 {}
@ -42,4 +43,5 @@
[components/discover-list-item-full [components/discover-list-item-full
{:message message {:message message
:show-separator? (not= (inc i) (count discoveries)) :show-separator? (not= (inc i) (count discoveries))
:contacts contacts
:current-account current-account}]))]]]])) :current-account current-account}]))]]]]))

View File

@ -9,7 +9,8 @@
(defview discover-all-recent [] (defview discover-all-recent []
(letsubs [discoveries [:get-recent-discoveries] (letsubs [discoveries [:get-recent-discoveries]
tabs-hidden? [:tabs-hidden?] tabs-hidden? [:tabs-hidden?]
current-account [:get-current-account]] current-account [:get-current-account]
contacts [:get-contacts]]
[react/view styles/all-recent-container [react/view styles/all-recent-container
[toolbar/toolbar2 {} [toolbar/toolbar2 {}
toolbar/default-nav-back toolbar/default-nav-back
@ -24,4 +25,5 @@
[components/discover-list-item-full [components/discover-list-item-full
{:message message {:message message
:show-separator? (not= (inc i) (count discoveries)) :show-separator? (not= (inc i) (count discoveries))
:contacts contacts
:current-account current-account}]))]]])])) :current-account current-account}]))]]])]))

View File

@ -19,6 +19,7 @@
(defview discover-search-results [] (defview discover-search-results []
(letsubs [{:keys [discoveries total]} [:get-popular-discoveries 250] (letsubs [{:keys [discoveries total]} [:get-popular-discoveries 250]
tags [:get :discover-search-tags] tags [:get :discover-search-tags]
contacts [:get-contacts]
current-account [:get-current-account]] current-account [:get-current-account]]
(let [datasource (to-datasource discoveries)] (let [datasource (to-datasource discoveries)]
[react/view styles/discover-tag-container [react/view styles/discover-tag-container
@ -39,6 +40,7 @@
:renderRow (fn [row _ _] :renderRow (fn [row _ _]
(react/list-item [components/discover-list-item (react/list-item [components/discover-list-item
{:message row {:message row
:current-account current-account}])) :current-account current-account
:contacts contacts}]))
:renderSeparator render-separator :renderSeparator render-separator
:style styles/status-list-inner}])]))) :style styles/status-list-inner}])])))

View File

@ -47,7 +47,7 @@
(re-frame/dispatch [:navigate-to :discover-search-results]))))}]) (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]]] (letsubs [discoveries [:get-popular-discoveries 1 [tag]]]
[react/view styles/popular-list-container [react/view styles/popular-list-container
[react/view styles/row [react/view styles/row
@ -65,7 +65,8 @@
(str (:total discoveries))]]] (str (:total discoveries))]]]
[components/discover-list-item {:message (first (:discoveries discoveries)) [components/discover-list-item {:message (first (:discoveries discoveries))
:show-separator? false :show-separator? false
:current-account current-account}]])) :current-account current-account
:contacts contacts}]]))
(defview popular-hashtags-preview [{:keys [contacts current-account]}] (defview popular-hashtags-preview [{:keys [contacts current-account]}]
(letsubs [popular-tags [:get-popular-tags 10]] (letsubs [popular-tags [:get-popular-tags 10]]
@ -85,7 +86,7 @@
:current-account current-account}])] :current-account current-account}])]
[empty-section :empty-hashtags :t/no-hashtags-discovered-title :t/no-hashtags-discovered-body])]))) [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)] (let [has-content? (seq discoveries)]
[react/view styles/recent-statuses-preview-container [react/view styles/recent-statuses-preview-container
[components/title :t/recent :t/all #(re-frame/dispatch [:navigate-to :discover-all-recent]) has-content?] [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 [react/view styles/recent-statuses-preview-content
[components/discover-list-item {:message discovery [components/discover-list-item {:message discovery
:show-separator? false :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])])) [empty-section :empty-recent :t/no-statuses-discovered :t/no-statuses-discovered-body])]))
(def public-chats-mock-data (def public-chats-mock-data
@ -147,7 +149,9 @@
[toolbar-view (and current-view? [toolbar-view (and current-view?
(= show-search :discover)) search-text] (= show-search :discover)) search-text]
[react/scroll-view styles/list-container [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 [popular-hashtags-preview {:contacts contacts
:current-account current-account}] :current-account current-account}]
[all-dapps/preview all-dapps] [all-dapps/preview all-dapps]