From 06aa4671b69f563e3edf20516173ade6a2975127 Mon Sep 17 00:00:00 2001 From: Ibrahem Khalil Date: Tue, 9 Apr 2024 21:46:58 +0200 Subject: [PATCH] Sometimes toast about old join community notification starts appearing on every login (#19557) --- fastlane/Gemfile.lock | 1 + src/status_im/constants.cljs | 2 ++ .../contexts/communities/events.cljs | 15 +++++-------- .../push_notifications/local/events.cljs | 22 +++++++++++++++---- status-go-version.json | 6 ++--- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/fastlane/Gemfile.lock b/fastlane/Gemfile.lock index 5cefe65f15..0d343bb392 100644 --- a/fastlane/Gemfile.lock +++ b/fastlane/Gemfile.lock @@ -217,6 +217,7 @@ GEM PLATFORMS arm64-darwin-22 + x86_64-darwin-22 DEPENDENCIES activesupport (>= 6.1.7.3, < 7.1.0) diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index a9f8ec200a..c2acbe45b7 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -488,3 +488,5 @@ (def ^:const alert-banner-height 40) (def ^:const status-hostname "status.app") + +(def ^:const community-joined-notification-type "communityJoined") diff --git a/src/status_im/contexts/communities/events.cljs b/src/status_im/contexts/communities/events.cljs index c9020ff410..cc52bbb3a7 100644 --- a/src/status_im/contexts/communities/events.cljs +++ b/src/status_im/contexts/communities/events.cljs @@ -59,16 +59,11 @@ (defn- handle-my-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)) - (assoc-in db [:communities/my-pending-requests-to-join community-id] request) - (and (= constants/community-request-to-join-state-accepted state) (not deleted)) - (do (rf/dispatch [:toasts/upsert - {: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)))) + (cond (and (= constants/community-request-to-join-state-pending state) (not deleted)) + (assoc-in db [:communities/my-pending-requests-to-join community-id] request) + (and (= constants/community-request-to-join-state-accepted state) (not deleted)) + (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 [db {:keys [id community-id deleted] :as request}] diff --git a/src/status_im/contexts/profile/push_notifications/local/events.cljs b/src/status_im/contexts/profile/push_notifications/local/events.cljs index 4946ef8915..73990484da 100644 --- a/src/status_im/contexts/profile/push_notifications/local/events.cljs +++ b/src/status_im/contexts/profile/push_notifications/local/events.cljs @@ -2,9 +2,13 @@ (:require [legacy.status-im.notifications.wallet :as notifications.wallet] [react-native.platform :as platform] + [status-im.constants :as constants] status-im.contexts.profile.push-notifications.local.effects + [utils.i18n :as i18n] [utils.re-frame :as rf])) +(def ^:private push-notification-types + #{"transaction" "message"}) (defn foreground-chat? [{{:keys [current-chat-id view-id]} :db} chat-id] @@ -21,6 +25,14 @@ (or (= app-state "background") (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 [cofx {:keys [bodyType] :as notification}] (assoc @@ -32,7 +44,9 @@ bodyType)) (rf/defn process - [cofx event] - (if platform/ios? - {:effects/push-notifications-local-present-ios (create-notification nil event)} - {:effects/push-notifications-local-present-android (create-notification cofx event)})) + [cofx {:keys [bodyType] :as event}] + (if (push-notification-types bodyType) + (if platform/ios? + {: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))) diff --git a/status-go-version.json b/status-go-version.json index 374cb3f824..e73dfaceed 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -3,7 +3,7 @@ "_comment": "Instead use: scripts/update-status-go.sh ", "owner": "status-im", "repo": "status-go", - "version": "v0.179.0", - "commit-sha1": "0db27a8be6b482c3d4687909e156e38654911f88", - "src-sha256": "0qcdf90sz0y0486dsgjindanavilkh9czzijlk8r0zz867n5b896" + "version": "v0.179.2", + "commit-sha1": "18cc3a16d5db25e653e9f90add48a6807f6f96c5", + "src-sha256": "1zswv57kd7z2ccad7kjad31a3f5dgj16g36wipb6xfd6qklkd54y" }