Skip to content

Commit ac1de8c

Browse files
committed
Fixed incorrect parameters provided to Command#yield-control
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
1 parent 75af388 commit ac1de8c

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

src/status_im/chat/commands/core.cljs

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[status-im.chat.constants :as chat.constants]
77
[status-im.chat.commands.protocol :as protocol]
88
[status-im.chat.commands.impl.transactions :as transactions]
9+
[status-im.contact.db :as db]
910
[status-im.utils.handlers :as handlers]
1011
[status-im.utils.fx :as fx]))
1112

@@ -34,13 +35,16 @@
3435
[type]
3536
(keyword (str (protocol/id type) "-button")))
3637

38+
(defn- contact->address [contact]
39+
(str "0x" (db/public-key->address contact)))
40+
3741
(defn add-chat-contacts
3842
"Enrich command-message by adding contact list of the current private or group chat"
3943
[contacts {:keys [public? group-chat] :as command-message}]
4044
(cond
4145
public? command-message
42-
group-chat (assoc command-message :contacts (map status-im.contact.db/public-key->address contacts))
43-
:else (assoc command-message :contact (status-im.contact.db/public-key->address (first contacts)))))
46+
group-chat (assoc command-message :contacts (map contact->address contacts))
47+
:else (assoc command-message :contact (contact->address (first contacts)))))
4448

4549
(defn enrich-command-message-for-events
4650
"adds new pairs to command-message to be consumed by extension events"

src/status_im/chat/commands/sending.cljs

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
;; errors during validation
3232
{:db (chat/set-chat-ui-props db {:validation-messages validation-error})}
3333
;; no errors
34-
(if (satisfies? protocol/Yielding type)
35-
;; yield control implemented, don't send the message
36-
(protocol/yield-control type parameter-map cofx)
37-
;; no yield control, proceed with sending the command message
38-
(let [command-message (create-command-message chat-id type parameter-map cofx)]
34+
(let [command-message (commands/enrich-command-message-for-events db (create-command-message chat-id type parameter-map cofx))]
35+
(if (satisfies? protocol/Yielding type)
36+
;; yield control implemented, don't send the message
37+
(protocol/yield-control type command-message cofx)
38+
;; no yield control, proceed with sending the command message
3939
(fx/merge cofx
40-
#(protocol/on-send type (commands/enrich-command-message-for-events db command-message) %)
40+
#(protocol/on-send type command-message %)
4141
(commands.input/set-command-reference nil)
4242
(chat.message/send-message command-message)))))))
4343

test/cljs/status_im/test/chat/commands/core.cljs

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@
111111
"0x04b790f2c3f4079f35a1fa396465ceb243cc446c9af211d0a1774f869eb9632a67a6e664e24075ec5c5a8a95a509a2a8173dbfeb88af372e784a37fecc1b5c0ba5"
112112
"0x04cc3cec3f88dc1a39e224388f0304023fc78c2a7d05e4ebd61638192cc592d2c13d8f081b5d9995dbfcbe45a4ca7eb80d5c505eee660e8fee0df2da222f047287"})
113113

114-
(def contacts_addresses '("5adf1b9e1fa4bd4889fecd598b45079045d98f0e"
115-
"21631d18d9681d4ffdd460fc45fa52159fcd95c8"
116-
"5541e3be81b76d76cdbf968516caa5a5b773763b"))
114+
(def contacts_addresses '("0x5adf1b9e1fa4bd4889fecd598b45079045d98f0e"
115+
"0x21631d18d9681d4ffdd460fc45fa52159fcd95c8"
116+
"0x5541e3be81b76d76cdbf968516caa5a5b773763b"))
117117

118118
(deftest enrich-command-message-for-events-test-public
119119
(let [db {:chats {"1" {:contacts nil :public? true :group-chat false}}}
@@ -137,4 +137,4 @@
137137
enriched-msg (core/enrich-command-message-for-events db msg)]
138138
(testing "command-message correctly enriched - 1on1 chat"
139139
(is (= enriched-msg
140-
(assoc msg :public? false :group-chat false :contact (first contacts_addresses)))))))
140+
(assoc msg :public? false :group-chat false :contact (first contacts_addresses)))))))

0 commit comments

Comments
 (0)