fix activity center unique constraint error (#13088)

This commit is contained in:
Parvesh Monu 2022-02-09 19:00:32 +05:30 committed by GitHub
parent e1e709220e
commit e59a2663f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 19 deletions

View File

@ -56,13 +56,14 @@
(fx/defn accept-activity-center-notifications
{:events [:accept-activity-center-notifications]}
[{:keys [db]} ids]
{:db (update-in db [:activity.center/notifications :notifications]
(fn [items] (remove #(get ids (:id %)) items)))
::json-rpc/call [{:method (json-rpc/call-ext-method "acceptActivityCenterNotifications")
:params [ids]
:js-response true
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
:on-error #()}]})
(when (seq ids)
{:db (update-in db [:activity.center/notifications :notifications]
(fn [items] (remove #(get ids (:id %)) items)))
::json-rpc/call [{:method (json-rpc/call-ext-method "acceptActivityCenterNotifications")
:params [ids]
:js-response true
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
:on-error #(log/info "unable to accept activity center notifications" %)}]}))
(fx/defn accept-all-activity-center-notifications-from-chat
{:events [:accept-all-activity-center-notifications-from-chat]}
@ -72,15 +73,16 @@
notifications-from-chat-not-read (filter #(and (= chat-id (:chat-id %))
(not (:read %))) notifications)
ids (map :id notifications-from-chat)]
{:db (-> db
(update-in [:activity.center/notifications :notifications]
(fn [items] (filter #(not (= chat-id (:chat-id %))) items)))
(update :activity.center/notifications-count - (min (db :activity.center/notifications-count) (count notifications-from-chat-not-read))))
::json-rpc/call [{:method (json-rpc/call-ext-method "acceptActivityCenterNotifications")
:params [ids]
:js-response true
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
:on-error #()}]}))
(when (seq ids)
{:db (-> db
(update-in [:activity.center/notifications :notifications]
(fn [items] (filter #(not (= chat-id (:chat-id %))) items)))
(update :activity.center/notifications-count - (min (db :activity.center/notifications-count) (count notifications-from-chat-not-read))))
::json-rpc/call [{:method (json-rpc/call-ext-method "acceptActivityCenterNotifications")
:params [ids]
:js-response true
:on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])
:on-error #(log/info "unable to accept activity center notifications" %)}]})))
(fx/defn accept-activity-center-notification-and-open-chat
{:events [:accept-activity-center-notification-and-open-chat]}

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.93.4",
"commit-sha1": "fb1f95a38f6b2a8a51da3f0c4b2bbacade084e70",
"src-sha256": "0dsc1x6kbxaiknb4706j0bzsca2kjwn1pnd32irxz1f41yqqsqgh"
"version": "v0.93.5",
"commit-sha1": "54b35b051052a0eaa74e4d0b123aca3427a27734",
"src-sha256": "14d55yd4rdm9hdc5k888xlm5sjl3iclggzrgxsmjlvfvcg81lf85"
}