Sometimes toast about old join community notification starts appearing on every login (#19557)
This commit is contained in:
parent
7eaa5f6bb1
commit
06aa4671b6
|
@ -217,6 +217,7 @@ GEM
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
arm64-darwin-22
|
arm64-darwin-22
|
||||||
|
x86_64-darwin-22
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
activesupport (>= 6.1.7.3, < 7.1.0)
|
activesupport (>= 6.1.7.3, < 7.1.0)
|
||||||
|
|
|
@ -488,3 +488,5 @@
|
||||||
(def ^:const alert-banner-height 40)
|
(def ^:const alert-banner-height 40)
|
||||||
|
|
||||||
(def ^:const status-hostname "status.app")
|
(def ^:const status-hostname "status.app")
|
||||||
|
|
||||||
|
(def ^:const community-joined-notification-type "communityJoined")
|
||||||
|
|
|
@ -59,16 +59,11 @@
|
||||||
|
|
||||||
(defn- handle-my-request
|
(defn- handle-my-request
|
||||||
[db {:keys [community-id state deleted] :as request}]
|
[db {:keys [community-id state deleted] :as request}]
|
||||||
(let [{:keys [name]} (get-in db [:communities community-id])]
|
(cond (and (= constants/community-request-to-join-state-pending state) (not deleted))
|
||||||
(cond (and (= constants/community-request-to-join-state-pending state) (not deleted))
|
(assoc-in db [:communities/my-pending-requests-to-join community-id] request)
|
||||||
(assoc-in db [:communities/my-pending-requests-to-join community-id] request)
|
(and (= constants/community-request-to-join-state-accepted state) (not deleted))
|
||||||
(and (= constants/community-request-to-join-state-accepted state) (not deleted))
|
(update-in db [:communities/my-pending-requests-to-join] dissoc community-id)
|
||||||
(do (rf/dispatch [:toasts/upsert
|
:else (update-in db [:communities/my-pending-requests-to-join] dissoc community-id)))
|
||||||
{:id :joined-community
|
|
||||||
:type :positive
|
|
||||||
:text (i18n/label :t/joined-community {:community name})}])
|
|
||||||
(update-in db [:communities/my-pending-requests-to-join] dissoc community-id))
|
|
||||||
:else (update-in db [:communities/my-pending-requests-to-join] dissoc community-id))))
|
|
||||||
|
|
||||||
(defn handle-admin-request
|
(defn handle-admin-request
|
||||||
[db {:keys [id community-id deleted] :as request}]
|
[db {:keys [id community-id deleted] :as request}]
|
||||||
|
|
|
@ -2,9 +2,13 @@
|
||||||
(:require
|
(:require
|
||||||
[legacy.status-im.notifications.wallet :as notifications.wallet]
|
[legacy.status-im.notifications.wallet :as notifications.wallet]
|
||||||
[react-native.platform :as platform]
|
[react-native.platform :as platform]
|
||||||
|
[status-im.constants :as constants]
|
||||||
status-im.contexts.profile.push-notifications.local.effects
|
status-im.contexts.profile.push-notifications.local.effects
|
||||||
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
(def ^:private push-notification-types
|
||||||
|
#{"transaction" "message"})
|
||||||
|
|
||||||
(defn foreground-chat?
|
(defn foreground-chat?
|
||||||
[{{:keys [current-chat-id view-id]} :db} chat-id]
|
[{{:keys [current-chat-id view-id]} :db} chat-id]
|
||||||
|
@ -21,6 +25,14 @@
|
||||||
(or (= app-state "background")
|
(or (= app-state "background")
|
||||||
(not (foreground-chat? cofx chat-id))))))
|
(not (foreground-chat? cofx chat-id))))))
|
||||||
|
|
||||||
|
(defn show-community-joined-toast
|
||||||
|
[{:keys [bodyType title]}]
|
||||||
|
(when (= bodyType constants/community-joined-notification-type)
|
||||||
|
{:dispatch [:toasts/upsert
|
||||||
|
{:id :joined-community
|
||||||
|
:type :positive
|
||||||
|
:text (i18n/label :t/joined-community {:community title})}]}))
|
||||||
|
|
||||||
(defn create-notification
|
(defn create-notification
|
||||||
[cofx {:keys [bodyType] :as notification}]
|
[cofx {:keys [bodyType] :as notification}]
|
||||||
(assoc
|
(assoc
|
||||||
|
@ -32,7 +44,9 @@
|
||||||
bodyType))
|
bodyType))
|
||||||
|
|
||||||
(rf/defn process
|
(rf/defn process
|
||||||
[cofx event]
|
[cofx {:keys [bodyType] :as event}]
|
||||||
(if platform/ios?
|
(if (push-notification-types bodyType)
|
||||||
{:effects/push-notifications-local-present-ios (create-notification nil event)}
|
(if platform/ios?
|
||||||
{:effects/push-notifications-local-present-android (create-notification cofx event)}))
|
{:effects/push-notifications-local-present-ios (create-notification nil event)}
|
||||||
|
{:effects/push-notifications-local-present-android (create-notification cofx event)})
|
||||||
|
(show-community-joined-toast event)))
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "v0.179.0",
|
"version": "v0.179.2",
|
||||||
"commit-sha1": "0db27a8be6b482c3d4687909e156e38654911f88",
|
"commit-sha1": "18cc3a16d5db25e653e9f90add48a6807f6f96c5",
|
||||||
"src-sha256": "0qcdf90sz0y0486dsgjindanavilkh9czzijlk8r0zz867n5b896"
|
"src-sha256": "1zswv57kd7z2ccad7kjad31a3f5dgj16g36wipb6xfd6qklkd54y"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue