[#3350]: 2 send commands are shown if chat contains 1 or more request messages

Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
alwxndr 2018-02-26 16:11:45 +01:00 committed by Julien Eluard
parent 64b248268d
commit 80b1edfff6
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
1 changed files with 12 additions and 26 deletions

View File

@ -17,35 +17,21 @@
:number-of-lines 2}
description]]])
(defview response-item [{:keys [name description]
{:keys [message-id]} :request :as command} last?]
[{{:keys [params]} :content} [:get-current-chat-message message-id]]
[suggestion-item
{:on-press #(let [metadata (assoc params :to-message-id message-id)]
(re-frame/dispatch [:select-chat-input-command command metadata]))
:name (commands-model/command-name command)
:description description
:last? last?}])
(defn command-item [{:keys [name description bot] :as command} last?]
[suggestion-item
{:on-press #(re-frame/dispatch [:select-chat-input-command command nil])
:name (commands-model/command-name command)
:description description
:last? last?}])
(defview suggestions-view []
(letsubs [responses [:get-available-responses]
commands [:get-available-commands]]
[expandable/expandable-view {:key :suggestions}
(letsubs [commands [:get-available-commands]]
[expandable/expandable-view {:key :suggestions
:draggable? false
:height (* (count commands)
(+ style/item-height
style/border-height))
:dynamic-height? true}
[react/view
[react/scroll-view {:keyboard-should-persist-taps :always
:bounces false}
(when (seq responses)
(for [[i response] (map-indexed vector responses)]
^{:key i}
[response-item response (= i (dec (count responses)))]))
(when (seq commands)
(for [[i command] (map-indexed vector commands)]
(for [[i {:keys [description] :as command}] (map-indexed vector commands)]
^{:key i}
[command-item command (= i (dec (count commands)))]))]]]))
[suggestion-item {:on-press #(re-frame/dispatch [:select-chat-input-command command nil])
:name (commands-model/command-name command)
:description description
:last? (= i (dec (count commands)))}]))]]]))