allows markup returned from bot's init function to be shown

This commit is contained in:
Roman Volosovskyi 2017-06-04 10:51:22 +03:00 committed by Roman Volosovskyi
parent 6f6849f635
commit 5b69439d3d
4 changed files with 14 additions and 11 deletions

View File

@ -56,6 +56,7 @@ function superSuggestion(params, context) {
var validationText = "";
if (typeof params !== 'undefined') {
if (isNaN(params.message)) {
validationText = "That's not a float number!";
} else if (parseFloat(params.message) > balance) {
@ -63,7 +64,7 @@ function superSuggestion(params, context) {
"Input value is too big!" +
" You have only " + balance + " ETH on your balance!";
}
}
status.updateDb({
balance: balance,
validationText: validationText
@ -75,6 +76,7 @@ function superSuggestion(params, context) {
var cnt = 0;
status.addListener("on-message-input-change", superSuggestion);
status.addListener("init", superSuggestion);
status.addListener("on-message-send", function (params, context) {
cnt++;
if (isNaN(params.message)) {

View File

@ -258,7 +258,7 @@
(init-console-chat true)))))
(defmethod nav/preload-data! :chat
[{:keys [current-chat-id] :as db} [_ _ id]]
[{:keys [current-chat-id current-account-id] :as db} [_ _ id]]
(let [chat-id (or id current-chat-id)
messages (get-in db [:chats chat-id :messages])
command? (= :command (get-in db [:edit-mode chat-id]))
@ -271,7 +271,8 @@
call-init-command #(when (and (not was-opened?) bot-url)
(status/call-function!
{:chat-id chat-id
:function :init}))]
:function :init
:context {:from current-account-id}}))]
(dispatch [:load-requests! chat-id])
;; todo rewrite this. temporary fix for https://github.com/status-im/status-react/issues/607
#_(dispatch [:load-commands! chat-id])

View File

@ -103,7 +103,8 @@
suggestions (suggestions/get-command-suggestions db chat-text)
global-commands (suggestions/get-global-command-suggestions db chat-text)
{:keys [dapp?]} (get-in db [:contacts chat-id])]
(when (and dapp? (every? empty? [requests suggestions]))
(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]))
(-> db
(assoc-in [:chats chat-id :request-suggestions] requests)

View File

@ -122,7 +122,6 @@
input-text (subscribe [:chat :input-text])
validation-messages (subscribe [:chat-ui-props :validation-messages])]
(reaction (and @chat-parameter-box
(not (str/blank? @input-text))
(not @validation-messages)
(not @show-suggestions?))))))