Improve notifications life-cycle (#13248)
This commit is contained in:
parent
cde0abd238
commit
ef95a59b0a
|
@ -135,7 +135,9 @@
|
|||
(update :chats #(apply dissoc % removed-chats))
|
||||
(update :chats-home-list set/difference removed-chats))}
|
||||
(when (not-empty removed-chats)
|
||||
{:clear-multiple-message-notifications removed-chats}))
|
||||
{:clear-message-notifications
|
||||
[removed-chats
|
||||
(get-in db [:multiaccount :remote-push-notifications-enabled?])]}))
|
||||
leave-removed-chat)))
|
||||
|
||||
(fx/defn clear-history
|
||||
|
@ -223,6 +225,8 @@
|
|||
{:events [:chat.ui/remove-chat]}
|
||||
[{:keys [db now] :as cofx} chat-id]
|
||||
(fx/merge cofx
|
||||
{:clear-message-notifications
|
||||
[[chat-id] (get-in db [:multiaccount :remote-push-notifications-enabled?])]}
|
||||
(deactivate-chat chat-id)
|
||||
(offload-messages chat-id)
|
||||
(when (not (= (:view-id db) :home))
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
[status-im.chat.models.message-list :as message-list]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.chat.models.pin-message :as models.pin-message]))
|
||||
[status-im.chat.models.pin-message :as models.pin-message]
|
||||
[status-im.notifications-center.core :as notification-center]))
|
||||
|
||||
(defn cursor->clock-value
|
||||
[^js cursor]
|
||||
|
@ -66,29 +67,37 @@
|
|||
|
||||
(fx/defn handle-mark-all-read-successful
|
||||
{:events [::mark-all-read-successful]}
|
||||
[{:keys [db]} chat-id]
|
||||
{:db (mark-chat-all-read db chat-id)})
|
||||
[{:keys [db] :as cofx} chat-id]
|
||||
(fx/merge cofx
|
||||
{:db (mark-chat-all-read db chat-id)}
|
||||
(notification-center/get-activity-center-notifications-count)))
|
||||
|
||||
(fx/defn handle-mark-all-read-in-community-successful
|
||||
{:events [::mark-all-read-in-community-successful]}
|
||||
[{:keys [db]} chat-ids]
|
||||
{:db (reduce mark-chat-all-read db chat-ids)})
|
||||
[{:keys [db] :as cofx} chat-ids]
|
||||
(fx/merge cofx
|
||||
{:db (reduce mark-chat-all-read db chat-ids)}
|
||||
(notification-center/get-activity-center-notifications-count)))
|
||||
|
||||
(fx/defn handle-mark-all-read
|
||||
{:events [:chat.ui/mark-all-read-pressed :chat/mark-all-as-read]}
|
||||
[_ chat-id]
|
||||
{:clear-message-notifications chat-id
|
||||
[{db :db} chat-id]
|
||||
{:clear-message-notifications [[chat-id]
|
||||
(get-in db [:multiaccount :remote-push-notifications-enabled?])]
|
||||
::json-rpc/call [{:method (json-rpc/call-ext-method "markAllRead")
|
||||
:params [chat-id]
|
||||
:on-success #(re-frame/dispatch [::mark-all-read-successful chat-id])}]})
|
||||
|
||||
(fx/defn handle-mark-mark-all-read-in-community
|
||||
{:events [:chat.ui/mark-all-read-in-community-pressed]}
|
||||
[_ community-id]
|
||||
{:clear-message-notifications community-id
|
||||
::json-rpc/call [{:method (json-rpc/call-ext-method "markAllReadInCommunity")
|
||||
:params [community-id]
|
||||
:on-success #(re-frame/dispatch [::mark-all-read-in-community-successful %])}]})
|
||||
[{db :db} community-id]
|
||||
(let [community-chat-ids (map #(str community-id %)
|
||||
(keys (get-in db [:communities community-id :chats])))]
|
||||
{:clear-message-notifications [community-chat-ids
|
||||
(get-in db [:multiaccount :remote-push-notifications-enabled?])]
|
||||
::json-rpc/call [{:method (json-rpc/call-ext-method "markAllReadInCommunity")
|
||||
:params [community-id]
|
||||
:on-success #(re-frame/dispatch [::mark-all-read-in-community-successful %])}]}))
|
||||
|
||||
(fx/defn messages-loaded
|
||||
"Loads more messages for current chat"
|
||||
|
|
|
@ -103,7 +103,8 @@
|
|||
[cofx response-js]
|
||||
(fx/merge cofx
|
||||
(handle-response cofx response-js)
|
||||
(navigation/pop-to-root-tab :chat-stack)))
|
||||
(navigation/pop-to-root-tab :chat-stack)
|
||||
(notification-center/get-activity-center-notifications-count)))
|
||||
|
||||
(fx/defn joined
|
||||
{:events [::joined ::requested-to-join]}
|
||||
|
@ -156,14 +157,18 @@
|
|||
|
||||
(fx/defn leave
|
||||
{:events [::leave]}
|
||||
[cofx community-id]
|
||||
{::json-rpc/call [{:method "wakuext_leaveCommunity"
|
||||
:params [community-id]
|
||||
:js-response true
|
||||
:on-success #(re-frame/dispatch [::left %])
|
||||
:on-error #(do
|
||||
(log/error "failed to leave community" community-id %)
|
||||
(re-frame/dispatch [::failed-to-leave %]))}]})
|
||||
[{:keys [db] :as cofx} community-id]
|
||||
(let [community-chat-ids (map #(str community-id %)
|
||||
(keys (get-in db [:communities community-id :chats])))]
|
||||
{:clear-message-notifications [community-chat-ids
|
||||
(get-in db [:multiaccount :remote-push-notifications-enabled?])]
|
||||
::json-rpc/call [{:method "wakuext_leaveCommunity"
|
||||
:params [community-id]
|
||||
:js-response true
|
||||
:on-success #(re-frame/dispatch [::left %])
|
||||
:on-error #(do
|
||||
(log/error "failed to leave community" community-id %)
|
||||
(re-frame/dispatch [::failed-to-leave %]))}]}))
|
||||
|
||||
(fx/defn fetch [_]
|
||||
{::json-rpc/call [{:method "wakuext_communities"
|
||||
|
|
|
@ -44,7 +44,9 @@
|
|||
{:db (-> db
|
||||
(update :chats dissoc public-key)
|
||||
(update :chats-home-list disj public-key)
|
||||
(assoc-in [:contacts/contacts public-key :added] false))}
|
||||
(assoc-in [:contacts/contacts public-key :added] false))
|
||||
:clear-message-notifications
|
||||
[[public-key] (get-in db [:multiaccount :remote-push-notifications-enabled?])]}
|
||||
(notification-center/get-activity-center-notifications-count)
|
||||
fxs)))
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.i18n.i18n :as i18n]))
|
||||
[status-im.i18n.i18n :as i18n]
|
||||
[status-im.notifications-center.core :as notification-center]))
|
||||
|
||||
(fx/defn navigate-chat-updated
|
||||
{:events [:navigate-chat-updated]}
|
||||
|
@ -20,9 +21,11 @@
|
|||
|
||||
(fx/defn handle-chat-removed
|
||||
{:events [:chat-removed]}
|
||||
[_ response]
|
||||
{:dispatch-n [[:sanitize-messages-and-process-response response]
|
||||
[:pop-to-root-tab :chat-stack]]})
|
||||
[cofx response]
|
||||
(fx/merge cofx
|
||||
{:dispatch-n [[:sanitize-messages-and-process-response response]
|
||||
[:pop-to-root-tab :chat-stack]]}
|
||||
(notification-center/get-activity-center-notifications-count)))
|
||||
|
||||
(fx/defn handle-chat-update
|
||||
{:events [:chat-updated]}
|
||||
|
|
|
@ -102,18 +102,19 @@
|
|||
(pn-android/disable-notifications)
|
||||
(.abandonPermissions ^js pn-ios))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:clear-message-notifications
|
||||
(fn [chat-id]
|
||||
(when platform/android?
|
||||
(pn-android/clear-message-notifications chat-id))))
|
||||
(defn clear-all-message-notifications []
|
||||
(if platform/android?
|
||||
(pn-android/clear-all-message-notifications)
|
||||
(.removeAllDeliveredNotifications ^js pn-ios)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:clear-multiple-message-notifications
|
||||
(fn [chat-ids]
|
||||
(when platform/android?
|
||||
(doseq [chat-id chat-ids]
|
||||
(pn-android/clear-message-notifications chat-id)))))
|
||||
:clear-message-notifications
|
||||
(fn [[chat-ids remote-push-notifications-enabled?]]
|
||||
(if remote-push-notifications-enabled?
|
||||
(clear-all-message-notifications)
|
||||
(when platform/android?
|
||||
(doseq [chat-id chat-ids]
|
||||
(pn-android/clear-message-notifications chat-id))))))
|
||||
|
||||
(fx/defn handle-enable-notifications-event
|
||||
{:events [:notifications/registered-for-push-notifications]}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||
"owner": "status-im",
|
||||
"repo": "status-go",
|
||||
"version": "v0.97.4",
|
||||
"commit-sha1": "724689086cdd3edef71a31c17e8888b1933c9ea5",
|
||||
"src-sha256": "091fc4ql9mp99ljw3l644bvkmwrfj2sq2mdhkwz6bn3z2maxgalk"
|
||||
"version": "v0.98.1",
|
||||
"commit-sha1": "3050106595104c16083a8a155d7b2167e7fda798",
|
||||
"src-sha256": "0dab072wmajdnp3hiyycxg1wn14a7l142z3768vwc2mz13nnld2r"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue