From ae856a926945d79e01d1816337604ec0845232ac Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Mon, 21 Nov 2016 17:11:11 +0200 Subject: [PATCH] fix #476 --- src/status_im/chat/subs.cljs | 5 +++++ src/status_im/chat/views/response.cljs | 18 ++++++++++-------- src/status_im/chat/views/suggestions.cljs | 20 ++++++++++++-------- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/status_im/chat/subs.cljs b/src/status_im/chat/subs.cljs index a8a5c4ff06..69a8b4a284 100644 --- a/src/status_im/chat/subs.cljs +++ b/src/status_im/chat/subs.cljs @@ -187,6 +187,11 @@ (map #(vector (:message-id %) %)) (into {})))))) +(register-sub :get-request + (fn [_ [_ message-id]] + (let [requests (subscribe [:get-requests-map])] + (reaction (get @requests message-id))))) + (register-sub :get-current-request (fn [] (let [requests (subscribe [:get-requests-map]) diff --git a/src/status_im/chat/views/response.cljs b/src/status_im/chat/views/response.cljs index 2991e200c6..abf858b3cd 100644 --- a/src/status_im/chat/views/response.cljs +++ b/src/status_im/chat/views/response.cljs @@ -38,6 +38,15 @@ (when icon-path [icon icon-path (st/command-icon color)])]) +(defn request-info-text [name chat-id added] + (let [name' (shortened-name (or name chat-id) 20)] + (str "By " name' ", " + (dt/format-date "MMM" added) + " " + (dt/get-ordinal-date added) + " at " + (dt/format-date "HH:mm" added)))) + (defview info-container [command] [{:keys [name chat-id]} [:get-current-chat] @@ -46,14 +55,7 @@ [text {:style st/command-name} (str (:description command) " " (label :t/request))] (when added - (let [name' (shortened-name (or name chat-id) 20)] - [text {:style st/message-info} - (str "By " name' ", " - (dt/format-date "MMM" added) - " " - (dt/get-ordinal-date added) - " at " - (dt/format-date "HH:mm" added))]))]) + [text {:style st/message-info} (request-info-text name chat-id added)])]) (defn request-info [response-height] (let [layout-height (subscribe [:max-layout-height :default]) diff --git a/src/status_im/chat/views/suggestions.cljs b/src/status_im/chat/views/suggestions.cljs index 8ba6532562..3a652167a6 100644 --- a/src/status_im/chat/views/suggestions.cljs +++ b/src/status_im/chat/views/suggestions.cljs @@ -19,26 +19,30 @@ [status-im.utils.platform :refer [ios?]] [status-im.chat.suggestions-responder :as resp] [status-im.chat.constants :as c] - [status-im.i18n :refer [label]])) + [status-im.i18n :refer [label]] + [status-im.chat.views.response :as response])) (defn set-command-input [command] (dispatch [:set-chat-command command])) (defview request-item [{:keys [type message-id]}] - [{:keys [color icon description] :as response} [:get-response type]] + [{:keys [color description] + icon-path :icon + :as response} [:get-response type] + {:keys [name chat-id]} [:get-current-chat] + {:keys [added]} [:get-request message-id]] [touchable-highlight {:on-press #(dispatch [:set-response-chat-command message-id type])} [view st/request-container [view st/request-icon-container [view (st/request-icon-background color) - (if icon - [image {:source {:uri icon} - :style st/request-icon}])]] + (when icon-path + [icon icon-path st/request-icon])]] [view st/request-info-container [text {:style st/request-info-description} description] - ;; todo stub - [text {:style st/request-message-info} - "By console, today at 14:50"]]]]) + (when added + [text {:style st/request-message-info} + (response/request-info-text name chat-id added)])]]]) (defn suggestion-list-item [[command {:keys [title description]