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?))
(into {}))
{:keys [dapp?]} (get-in db [:contacts chat-id])]
(if (and dapp? (str/blank? chat-text))
(dispatch [:set-in [:chats chat-id :parameter-boxes :message] nil])
(dispatch [::check-dapp-suggestions chat-id chat-text]))
(when dapp?
(if (str/blank? chat-text)
(dispatch [:set-in [:chats chat-id :parameter-boxes :message] nil])
(when (every? empty? [requests commands])
(dispatch [::check-dapp-suggestions chat-id chat-text]))))
(-> db
(assoc-in [:chats chat-id :request-suggestions] requests)
(assoc-in [:chats chat-id :command-suggestions] all-commands)))))

View File

@ -88,13 +88,13 @@
(subs command-name 1)))
possible-actions)
(first))]
{:command command
:metadata (if (not= :any to-message-id)
(assoc input-metadata :to-message-id to-message-id)
input-metadata)
:args (if (empty? seq-arguments)
(rest command-args)
seq-arguments)}))))
{:command command
:metadata (if (and (nil? (:to-message-id input-metadata)) (not= :any to-message-id))
(assoc input-metadata :to-message-id to-message-id)
input-metadata)
:args (if (empty? seq-arguments)
(rest command-args)
seq-arguments)}))))
([{:keys [current-chat-id] :as db} chat-id]
(selected-chat-command db chat-id (get-in db [:chats chat-id :input-text]))))

View File

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