Remove contact request notification from activity center when request is canceled

This commit is contained in:
Roman Volosovskyi 2022-08-10 13:43:58 +02:00
parent 901081a4cf
commit b06d63d200
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
3 changed files with 13 additions and 5 deletions

View File

@ -35,6 +35,7 @@
(def ^:const timeline-chat-type 5)
(def ^:const community-chat-type 6)
(def ^:const contact-request-message-state-none 0)
(def ^:const contact-request-message-state-pending 1)
(def ^:const contact-request-message-state-accepted 2)
(def ^:const contact-request-message-state-declined 3)

View File

@ -1928,19 +1928,25 @@
(re-frame/reg-sub
:activity.center/notifications-grouped-by-date
:<- [:activity.center/notifications]
(fn [{:keys [notifications]}]
:<- [:contacts/contacts]
(fn [[{:keys [notifications]} contacts]]
(let [supported-notifications
(filter (fn [{:keys [type last-message]}]
(filter (fn [{:keys [type last-message message]}]
(or (and (= constants/activity-center-notification-type-one-to-one-chat type)
(not (nil? last-message)))
(= constants/activity-center-notification-type-contact-request type)
(and (= constants/activity-center-notification-type-contact-request type)
(not= constants/contact-request-message-state-none
(-> contacts
(multiaccounts/contact-by-identity (:from message))
:contact-request-state)))
(= constants/activity-center-notification-type-contact-request-retracted type)
(= constants/activity-center-notification-type-private-group-chat type)
(= constants/activity-center-notification-type-reply type)
(= constants/activity-center-notification-type-mention type)))
notifications)]
(group-notifications-by-date
(map #(assoc % :timestamp (or (:timestamp %) (:timestamp (or (:message %) (:last-message %)))))
(map #(assoc % :timestamp (or (:timestamp %) (:timestamp (or (:message %) (:last-message %))))
:contact (multiaccounts/contact-by-identity contacts (get-in % [:message :from])))
supported-notifications)))))
;;WALLET TRANSACTIONS ==================================================================================================

View File

@ -132,4 +132,5 @@
constants/contact-request-message-state-declined
[quo/text {:style {:color colors/red}} (i18n/label :t/declined)]
constants/contact-request-message-state-pending
[contact-request-actions (:message-id message)])])]))
[contact-request-actions (:message-id message)]
nil)])]))