-
Notifications
You must be signed in to change notification settings - Fork 987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: cleanup events and tests #21885
base: develop
Are you sure you want to change the base?
Changes from all commits
2020f90
4ef6141
767ba11
30e0cae
79b5480
015e9a5
3a51fde
37f24c9
65a967e
b124a6b
05c8702
6424c86
474d14d
fd9c4cd
cf5ae68
8904eb3
077a336
c03e932
7d404b7
97a8c0a
b92f046
accbbe6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,75 @@ | |
:logs/set-level | ||
(fn [level] | ||
(setup level))) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I love this! |
||
(defn log-error | ||
([error] | ||
(log/error error)) | ||
([message error] | ||
(log/error message error)) | ||
([message context error] | ||
(log/error message context error))) | ||
|
||
(re-frame/reg-event-fx | ||
:log/error | ||
(fn [_ args] | ||
{:fx [[:effects.log/error args]]})) | ||
|
||
(re-frame/reg-fx | ||
:effects.log/error | ||
(fn [args] | ||
(apply log-error args))) | ||
|
||
(defn log-info | ||
([info] | ||
(log/info info)) | ||
([message info] | ||
(log/info message info)) | ||
([message context info] | ||
(log/info message context info))) | ||
|
||
(re-frame/reg-event-fx | ||
:log/info | ||
(fn [_ args] | ||
{:fx [[:effects.log/info args]]})) | ||
|
||
(re-frame/reg-fx | ||
:effects.log/info | ||
(fn [args] | ||
(apply log-info args))) | ||
|
||
(defn log-warn | ||
([warning] | ||
(log/warn warning)) | ||
([message warning] | ||
(log/warn message warning)) | ||
([message context warning] | ||
(log/warn message context warning))) | ||
|
||
(re-frame/reg-event-fx | ||
:log/warn | ||
(fn [_ args] | ||
{:fx [[:effects.log/warn args]]})) | ||
|
||
(re-frame/reg-fx | ||
:effects.log/warn | ||
(fn [args] | ||
(apply log-warn args))) | ||
|
||
(defn log-debug | ||
([value] | ||
(log/debug value)) | ||
([message value] | ||
(log/debug message value)) | ||
([message context value] | ||
(log/debug message context value))) | ||
|
||
(re-frame/reg-event-fx | ||
:log/debug | ||
(fn [_ args] | ||
{:fx [[:effects.log/debug args]]})) | ||
|
||
(re-frame/reg-fx | ||
:effects.log/debug | ||
(fn [args] | ||
(apply log-debug args))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
[re-frame.core :as re-frame] | ||
[status-im.common.json-rpc.events :as json-rpc] | ||
[status-im.constants :as constants] | ||
[taoensso.timbre :as log] | ||
[utils.i18n :as i18n] | ||
[utils.re-frame :as rf] | ||
[utils.transforms :as transforms])) | ||
|
@@ -85,7 +84,7 @@ | |
:params [] | ||
:js-response true | ||
:on-success [:contacts/contacts-loaded] | ||
:on-error #(log/error "failed to fetch contacts" %)}))) | ||
:on-error [:log/error "failed to fetch contacts"]}))) | ||
|
||
(defn send-contact-request | ||
[{:keys [db]} [id message]] | ||
|
@@ -94,40 +93,61 @@ | |
[{:method "wakuext_sendContactRequest" | ||
:js-response true | ||
:params [{:id id :message (or message (i18n/label :t/add-me-to-your-contacts))}] | ||
:on-error [:contact.ui/send-contact-request-failure id] | ||
:on-error [:contacts/send-contact-request-error id] | ||
:on-success [:transport/message-sent]}]]]})) | ||
|
||
(rf/reg-event-fx :contact.ui/send-contact-request send-contact-request) | ||
|
||
(defn send-contact-request-failure | ||
(defn send-contact-request-error | ||
[_ [id error]] | ||
(log/error "Failed to send contact request" | ||
{:error error | ||
:event :contact.ui/send-contact-request | ||
:id id})) | ||
{:fx [[:effects.log/error | ||
["Failed to send contact request" | ||
{:id id | ||
:error error | ||
:event :contact.ui/send-contact-request}]]]}) | ||
|
||
(rf/reg-event-fx :contact.ui/send-contact-request-failure send-contact-request-failure) | ||
(rf/reg-event-fx :contact.ui/send-contact-request-error send-contact-request-error) | ||
|
||
(rf/defn remove-contact | ||
(defn remove-contact | ||
"Remove a contact from current account's contact list" | ||
{:events [:contact.ui/remove-contact-pressed]} | ||
[{:keys [db]} {:keys [public-key]}] | ||
{:db (-> db | ||
(assoc-in [:contacts/contacts public-key :added?] false) | ||
(assoc-in [:contacts/contacts public-key :active?] false) | ||
(assoc-in [:contacts/contacts public-key :contact-request-state] | ||
constants/contact-request-state-none)) | ||
:json-rpc/call [{:method "wakuext_retractContactRequest" | ||
:params [{:id public-key}] | ||
:js-response true | ||
:on-success #(rf/dispatch [:sanitize-messages-and-process-response %]) | ||
:on-error #(log/error "failed to remove contact" public-key %)}]}) | ||
|
||
(rf/defn update-nickname | ||
{:events [:contacts/update-nickname]} | ||
[_ public-key nickname] | ||
{:json-rpc/call [{:method "wakuext_setContactLocalNickname" | ||
:params [{:id public-key :nickname nickname}] | ||
:js-response true | ||
:on-success #(rf/dispatch [:sanitize-messages-and-process-response %]) | ||
:on-error #(log/error "failed to set contact nickname " public-key nickname %)}]}) | ||
[{:keys [db]} [{:keys [public-key]}]] | ||
{:db (-> db | ||
(assoc-in [:contacts/contacts public-key :added?] false) | ||
(assoc-in [:contacts/contacts public-key :active?] false) | ||
(assoc-in [:contacts/contacts public-key :contact-request-state] | ||
constants/contact-request-state-none)) | ||
:fx [[:json-rpc/call | ||
[{:method "wakuext_retractContactRequest" | ||
:params [{:id public-key}] | ||
:js-response true | ||
:on-success [:sanitize-messages-and-process-response] | ||
:on-error [:contacts/remove-contact-error public-key]}]]]}) | ||
|
||
(rf/reg-event-fx :contact.ui/remove-contact-pressed remove-contact) | ||
Comment on lines
+111
to
+126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we're also migrating towards using the |
||
|
||
(defn remove-contact-error | ||
[_ [public-key error]] | ||
{:fx [[:effects.log/error ["failed to remove contact" public-key error]]]}) | ||
|
||
(rf/reg-event-fx :contacts/remove-contact-error remove-contact-error) | ||
|
||
(defn update-nickname | ||
[_ [public-key nickname]] | ||
{:fx [[:json-rpc/call | ||
[{:method "wakuext_setContactLocalNickname" | ||
:params [{:id public-key :nickname nickname}] | ||
:js-response true | ||
:on-success [:sanitize-messages-and-process-response] | ||
:on-error [:contacts/update-nickname-error public-key nickname]}]]]}) | ||
|
||
(rf/reg-event-fx :contacts/update-nickname update-nickname) | ||
|
||
(defn update-nickname-error | ||
[_ [public-key nickname error]] | ||
{:fx [[:effects.log/error | ||
["failed to set contact nickname" | ||
{:public-key public-key | ||
:nickname nickname} | ||
error]]]}) | ||
|
||
(rf/reg-event-fx :contacts/update-nickname-error update-nickname-error) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,8 +151,10 @@ | |
:effects.async-storage/set {:chat-id nil | ||
:key-uid nil}} | ||
(link-preview/reset-all) | ||
(delete-for-me/sync-all) | ||
(delete-message/send-all) | ||
(fn [cofx] | ||
(delete-for-me/sync-all cofx)) | ||
(fn [cofx] | ||
(delete-message/send-all cofx)) | ||
Comment on lines
+154
to
+157
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is correct @seanstrom. I had to do this a few times in the past. |
||
(offload-messages chat-id))))) | ||
|
||
(rf/defn deactivate-chat | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needed to be added while running tests locally, otherwise the
rf/merge
function wouldn't return a merged collection of effects.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!