From 80b1edfff695d87b8f7b1dfd80650ff41bf0c3c2 Mon Sep 17 00:00:00 2001 From: alwxndr Date: Mon, 26 Feb 2018 16:11:45 +0100 Subject: [PATCH] [#3350]: 2 send commands are shown if chat contains 1 or more request messages Signed-off-by: Julien Eluard --- .../chat/views/input/suggestions.cljs | 38 ++++++------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/src/status_im/chat/views/input/suggestions.cljs b/src/status_im/chat/views/input/suggestions.cljs index 9be43b8279..4cfdb60cf1 100644 --- a/src/status_im/chat/views/input/suggestions.cljs +++ b/src/status_im/chat/views/input/suggestions.cljs @@ -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)))}]))]]]))