This commit is contained in:
Roman Volosovskyi 2016-11-21 17:11:11 +02:00
parent 3efb8a7bb8
commit ae856a9269
3 changed files with 27 additions and 16 deletions

View File

@ -187,6 +187,11 @@
(map #(vector (:message-id %) %)) (map #(vector (:message-id %) %))
(into {})))))) (into {}))))))
(register-sub :get-request
(fn [_ [_ message-id]]
(let [requests (subscribe [:get-requests-map])]
(reaction (get @requests message-id)))))
(register-sub :get-current-request (register-sub :get-current-request
(fn [] (fn []
(let [requests (subscribe [:get-requests-map]) (let [requests (subscribe [:get-requests-map])

View File

@ -38,6 +38,15 @@
(when icon-path (when icon-path
[icon icon-path (st/command-icon color)])]) [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 (defview info-container
[command] [command]
[{:keys [name chat-id]} [:get-current-chat] [{:keys [name chat-id]} [:get-current-chat]
@ -46,14 +55,7 @@
[text {:style st/command-name} [text {:style st/command-name}
(str (:description command) " " (label :t/request))] (str (:description command) " " (label :t/request))]
(when added (when added
(let [name' (shortened-name (or name chat-id) 20)] [text {:style st/message-info} (request-info-text name chat-id added)])])
[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))]))])
(defn request-info [response-height] (defn request-info [response-height]
(let [layout-height (subscribe [:max-layout-height :default]) (let [layout-height (subscribe [:max-layout-height :default])

View File

@ -19,26 +19,30 @@
[status-im.utils.platform :refer [ios?]] [status-im.utils.platform :refer [ios?]]
[status-im.chat.suggestions-responder :as resp] [status-im.chat.suggestions-responder :as resp]
[status-im.chat.constants :as c] [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] (defn set-command-input [command]
(dispatch [:set-chat-command command])) (dispatch [:set-chat-command command]))
(defview request-item [{:keys [type message-id]}] (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 [touchable-highlight
{:on-press #(dispatch [:set-response-chat-command message-id type])} {:on-press #(dispatch [:set-response-chat-command message-id type])}
[view st/request-container [view st/request-container
[view st/request-icon-container [view st/request-icon-container
[view (st/request-icon-background color) [view (st/request-icon-background color)
(if icon (when icon-path
[image {:source {:uri icon} [icon icon-path st/request-icon])]]
:style st/request-icon}])]]
[view st/request-info-container [view st/request-info-container
[text {:style st/request-info-description} description] [text {:style st/request-info-description} description]
;; todo stub (when added
[text {:style st/request-message-info} [text {:style st/request-message-info}
"By console, today at 14:50"]]]]) (response/request-info-text name chat-id added)])]]])
(defn suggestion-list-item (defn suggestion-list-item
[[command {:keys [title description] [[command {:keys [title description]