Andrey Shovkoplyas 2017-07-14 14:00:42 +03:00 committed by Roman Volosovskyi
parent a0de31ebb6
commit f5348df929
3 changed files with 21 additions and 19 deletions

View File

@ -124,9 +124,11 @@
(remove (fn [[k {:keys [hidden?]}]] hidden?)) (remove (fn [[k {:keys [hidden?]}]] hidden?))
(into {})) (into {}))
{:keys [dapp?]} (get-in db [:contacts chat-id])] {:keys [dapp?]} (get-in db [:contacts chat-id])]
(if (and dapp? (str/blank? chat-text)) (when dapp?
(if (str/blank? chat-text)
(dispatch [:set-in [:chats chat-id :parameter-boxes :message] nil]) (dispatch [:set-in [:chats chat-id :parameter-boxes :message] nil])
(dispatch [::check-dapp-suggestions chat-id chat-text])) (when (every? empty? [requests commands])
(dispatch [::check-dapp-suggestions chat-id chat-text]))))
(-> db (-> db
(assoc-in [:chats chat-id :request-suggestions] requests) (assoc-in [:chats chat-id :request-suggestions] requests)
(assoc-in [:chats chat-id :command-suggestions] all-commands))))) (assoc-in [:chats chat-id :command-suggestions] all-commands)))))

View File

@ -89,7 +89,7 @@
possible-actions) possible-actions)
(first))] (first))]
{:command command {:command command
:metadata (if (not= :any to-message-id) :metadata (if (and (nil? (:to-message-id input-metadata)) (not= :any to-message-id))
(assoc input-metadata :to-message-id to-message-id) (assoc input-metadata :to-message-id to-message-id)
input-metadata) input-metadata)
:args (if (empty? seq-arguments) :args (if (empty? seq-arguments)

View File

@ -56,13 +56,10 @@
:component-will-unmount :component-will-unmount
#(reset! loop? false) #(reset! loop? false)
:reagent-render :reagent-render
(fn [message-id {:keys [execute-immediately?] command-icon :icon :as command} status-initialized?] (fn [message-id {command-icon :icon :as command} on-press-handler]
(when command (when command
[touchable-highlight [touchable-highlight
{:on-press (if execute-immediately? {:on-press on-press-handler
#(dispatch [:execute-command-immediately command])
(when (and (not @answered?) status-initialized?)
#(set-chat-command message-id command)))
:style (st/command-request-image-touchable) :style (st/command-request-image-touchable)
:accessibility-label (id/chat-request-message-button (:name command))} :accessibility-label (id/chat-request-message-button (:name command))}
[animated-view {:style (st/command-request-image-view command scale-anim-val)} [animated-view {:style (st/command-request-image-view command scale-anim-val)}
@ -83,11 +80,14 @@
command (if (and params command) command (if (and params command)
(merge command {:prefill prefill (merge command {:prefill prefill
:prefill-bot-db (or prefill-bot-db prefillBotDb)}) :prefill-bot-db (or prefill-bot-db prefillBotDb)})
command)] command)
on-press-handler (if (:execute-immediately? command)
#(dispatch [:execute-command-immediately command])
(when (and (not @answered?) @status-initialized?)
#(set-chat-command message-id command)))]
[view st/comand-request-view [view st/comand-request-view
[touchable-highlight [touchable-highlight
{:on-press (when (and (not @answered?) @status-initialized?) {:on-press on-press-handler}
#(set-chat-command message-id command))}
[view st/command-request-message-view [view st/command-request-message-view
(if (and @markup (if (and @markup
(not (string? @markup))) (not (string? @markup)))
@ -100,4 +100,4 @@
[text {:style st/style-sub-text [text {:style st/style-sub-text
:font :default} :font :default}
(:request-text command)]]) (:request-text command)]])
[request-button message-id command @status-initialized?]])))) [request-button message-id command on-press-handler]]))))