[#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:
parent
64b248268d
commit
80b1edfff6
|
@ -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)))}]))]]]))
|
||||
|
|
Loading…
Reference in New Issue