Make Andy happy again (by fixing debug mode)
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
c9be1f7c4a
commit
49a53645fb
|
@ -1,7 +1,5 @@
|
|||
(ns status-im.chat.events.commands
|
||||
(:require [cljs.reader :as reader]
|
||||
[clojure.string :as str]
|
||||
[re-frame.core :as re-frame]
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.i18n :as i18n]
|
||||
|
@ -69,7 +67,7 @@
|
|||
(handlers/register-handler-fx
|
||||
:execute-command-immediately
|
||||
[re-frame/trim-v]
|
||||
(fn [_ [{command-name :name :as command}]]
|
||||
(fn [_ [{command-name :name}]]
|
||||
(case (keyword command-name)
|
||||
:grant-permissions
|
||||
{:dispatch [:request-permissions
|
||||
|
|
|
@ -367,7 +367,7 @@
|
|||
(handlers/register-handler-fx
|
||||
::send-command
|
||||
message-model/send-interceptors
|
||||
(fn [{:keys [db] :as cofx} [{:keys [command] :as command-message}]]
|
||||
(fn [{:keys [db] :as cofx} [command-message]]
|
||||
(let [{:keys [current-public-key current-chat-id] :accounts/keys [current-account-id]} db
|
||||
new-db (-> (model/set-chat-ui-props db {:sending-in-progress? false})
|
||||
(clear-seq-arguments)
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
(ns status-im.chat.events.send-message
|
||||
(:require [re-frame.core :as re-frame]
|
||||
(:require [taoensso.timbre :as log]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.chat.models.message :as message-model]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.protocol.core :as protocol]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.utils.types :as types]
|
||||
[taoensso.timbre :as log]))
|
||||
[status-im.utils.types :as types]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:send-notification
|
||||
|
@ -36,8 +35,8 @@
|
|||
(handlers/register-handler-fx
|
||||
:chat-send-message/send-command
|
||||
message-model/send-interceptors
|
||||
(fn [cofx [add-to-chat-id params]]
|
||||
(message-model/send-command cofx add-to-chat-id params)))
|
||||
(fn [cofx [_ params]]
|
||||
(message-model/send-command cofx params)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:chat-send-message/from-jail
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
(ns status-im.chat.models.message
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.utils.core :as utils]
|
||||
[status-im.chat.events.console :as console-events]
|
||||
[status-im.chat.events.requests :as requests-events]
|
||||
[status-im.chat.models :as chat-model]
|
||||
[status-im.chat.models.commands :as commands-model]
|
||||
[status-im.utils.clocks :as clocks-utils]))
|
||||
[status-im.chat.models.commands :as commands-model]))
|
||||
|
||||
(defn- get-current-account
|
||||
[{:accounts/keys [accounts current-account-id]}]
|
||||
|
@ -267,7 +267,7 @@
|
|||
:show? true}))
|
||||
|
||||
(defn send-command
|
||||
[{{:keys [current-public-key chats] :as db} :db :keys [now random-id-seq] :as cofx} add-to-chat-id params]
|
||||
[{{:keys [current-public-key chats]} :db :keys [now random-id-seq] :as cofx} params]
|
||||
(let [{{:keys [handler-data
|
||||
command]
|
||||
:as content} :command
|
||||
|
@ -299,15 +299,18 @@
|
|||
(update fx' :dispatch-n into events))))))
|
||||
|
||||
(defn invoke-console-command-handler
|
||||
[{:keys [db] :as cofx} {:keys [chat-id command] :as command-params}]
|
||||
[{:keys [db] :as cofx} {:keys [command] :as command-params}]
|
||||
(let [fx-fn (get console-events/console-commands->fx (-> command :command :name))
|
||||
fx (fx-fn cofx command)]
|
||||
(merge fx (send-command (assoc cofx :db (or (:db fx) db)) chat-id command-params))))
|
||||
(let [command (send-command (assoc cofx :db (or (:db fx) db)) command-params)
|
||||
dn (concat (:dispatch-n fx) (:dispatch-n command))]
|
||||
;; Make sure `dispatch-n` do not collide
|
||||
;; TODO (jeluard) Refactor to rely on merge-fx and reduce creation of `dispatch-n`
|
||||
(merge {:dispatch-n dn} (dissoc fx :dispatch-n) (dissoc command :dispatch-n)))))
|
||||
|
||||
(defn invoke-command-handlers
|
||||
[{{:keys [bot-db]
|
||||
:accounts/keys [accounts current-account-id]
|
||||
:contacts/keys [contacts] :as db} :db}
|
||||
[{{:accounts/keys [accounts current-account-id]
|
||||
:contacts/keys [contacts]} :db}
|
||||
{{:keys [command params id]} :command
|
||||
:keys [chat-id address]
|
||||
:as orig-params}]
|
||||
|
@ -315,7 +318,6 @@
|
|||
handler-type (if (= :command type) :commands :responses)
|
||||
to (get-in contacts [chat-id :address])
|
||||
identity (or owner-id bot chat-id)
|
||||
bot-db (get bot-db (or bot chat-id))
|
||||
;; TODO what's actually semantic difference between `:parameters` and `:context`
|
||||
;; and do we have some clear API for both ? seems very messy and unorganized now
|
||||
jail-params {:parameters params
|
||||
|
@ -333,8 +335,8 @@
|
|||
[[:command-handler! chat-id orig-params jail-response]]))}}))
|
||||
|
||||
(defn process-command
|
||||
[{:keys [db] :as cofx} {:keys [command message chat-id] :as params}]
|
||||
(let [{:keys [command] :as content} command]
|
||||
[cofx {:keys [command chat-id] :as params}]
|
||||
(let [{:keys [command]} command]
|
||||
(cond
|
||||
(and (= constants/console-chat-id chat-id)
|
||||
(console-events/commands-names (:name command)))
|
||||
|
@ -344,4 +346,4 @@
|
|||
(invoke-command-handlers cofx params)
|
||||
|
||||
:else
|
||||
(send-command cofx chat-id params))))
|
||||
(send-command cofx params))))
|
||||
|
|
|
@ -5,14 +5,13 @@
|
|||
[status-im.utils.utils :refer [show-popup]]
|
||||
[status-im.utils.types :as types]
|
||||
[status-im.commands.utils :refer [reg-handler]]
|
||||
[status-im.ui.components.react :as r]
|
||||
[status-im.constants :refer [console-chat-id]]
|
||||
[status-im.i18n :refer [get-contact-translated]]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.data-store.local-storage :as local-storage]))
|
||||
|
||||
(defn command-handler!
|
||||
[_ [chat-id
|
||||
[_ [_
|
||||
{:keys [command] :as params}
|
||||
{:keys [result error]}]]
|
||||
(let [{:keys [returned]} result
|
||||
|
@ -23,19 +22,17 @@
|
|||
(dispatch [:set-chat-ui-props {:validation-messages markup}]))
|
||||
|
||||
result
|
||||
(let [command' (assoc command :handler-data returned)
|
||||
params' (assoc params :command command')]
|
||||
(dispatch [:chat-send-message/send-command chat-id params']))
|
||||
(dispatch [:chat-send-message/send-command (assoc-in params [:command :handler-data] returned)])
|
||||
|
||||
(not (or error handler-error))
|
||||
(dispatch [:chat-send-message/send-command chat-id params])
|
||||
(dispatch [:chat-send-message/send-command params])
|
||||
|
||||
:else nil)))
|
||||
|
||||
(defn suggestions-handler!
|
||||
[{:keys [chats] :as db}
|
||||
[{:keys [chat-id bot-id default-db command parameter-index result]}]]
|
||||
(let [{:keys [markup height] :as returned} (get-in result [:result :returned])
|
||||
(let [{:keys [markup] :as returned} (get-in result [:result :returned])
|
||||
contains-markup? (contains? returned :markup)
|
||||
current-input (get-in chats [chat-id :input-text])
|
||||
path (if command
|
||||
|
@ -49,7 +46,7 @@
|
|||
:db default-db}])))))
|
||||
|
||||
(defn suggestions-events-handler!
|
||||
[{:keys [bot-db] :as db} [bot-id [n & data :as ev] val]]
|
||||
[{:keys [bot-db]} [bot-id [n & data] val]]
|
||||
(log/debug "Suggestion event: " n (first data) val)
|
||||
(case (keyword n)
|
||||
:set-command-argument
|
||||
|
|
|
@ -89,7 +89,6 @@
|
|||
(defn add-pending-message!
|
||||
[web3 message]
|
||||
{:pre [(valid? :protocol/message message)]}
|
||||
(debug :add-pending-message! message)
|
||||
;; encryption can take some time, better to run asynchronously
|
||||
(async/go (async/>! pending-message-queue [web3 message])))
|
||||
|
||||
|
|
|
@ -15,6 +15,5 @@
|
|||
(defn post-message!
|
||||
[web3 message callback]
|
||||
{:pre [(valid? :shh/message message)]}
|
||||
(debug :post-message message)
|
||||
(let [shh (u/shh web3)]
|
||||
(.post shh (clj->js message) callback)))
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
|
||||
(defn- pretty-print-event [ctx]
|
||||
(let [[first second] (get-coeffect ctx :event)]
|
||||
(if (map? second)
|
||||
first
|
||||
(str first " " second))))
|
||||
(if (or (string? second) (keyword? second) (boolean? second))
|
||||
(str first " " second)
|
||||
first)))
|
||||
|
||||
(def debug-handlers-names
|
||||
"Interceptor which logs debug information to js/console for each event."
|
||||
|
|
Loading…
Reference in New Issue