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