From 064204256ea40d7a6d1c358ab06530752bbf6c00 Mon Sep 17 00:00:00 2001 From: Icaro Motta Date: Fri, 3 Mar 2023 10:34:55 -0300 Subject: [PATCH] Fix Activity Center popover not opening (#15239) Fixes #15230 - The popover state in the app db must be discarded before trying to open the Activity Center. This workaround is used in other parts of the app too. It's ugly, but the only quick fix I found. It's plenty obvious the popover component and all its surrounding logic should be revisited in the future. --- .../contexts/activity_center/events.cljs | 30 ++++++++++------- .../contexts/activity_center/events_test.cljs | 33 +++++++------------ 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/status_im2/contexts/activity_center/events.cljs b/src/status_im2/contexts/activity_center/events.cljs index 5fa566d425..6560621aa8 100644 --- a/src/status_im2/contexts/activity_center/events.cljs +++ b/src/status_im2/contexts/activity_center/events.cljs @@ -25,19 +25,25 @@ (rf/defn open-activity-center {:events [:activity-center/open]} [{:keys [db]} {:keys [filter-type filter-status]}] - {:db (cond-> db - filter-status - (assoc-in [:activity-center :filter :status] filter-status) + ;; It's essential to clean-up the popover state and delay the dispatch of the + ;; `:show-popover` event, otherwise the popover won't be displayed under + ;; certain conditions. See issue + ;; https://github.com/status-im/status-mobile/issues/15230 + {:db (cond-> (dissoc db :popover/popover) + filter-status + (assoc-in [:activity-center :filter :status] filter-status) - filter-type - (assoc-in [:activity-center :filter :type] filter-type)) - :dispatch [:show-popover - {:view :activity-center - :style {:margin 0} - :disable-touchable-overlay? true - :blur-view? true - :blur-view-props {:blur-amount 20 - :blur-type :dark}}]}) + filter-type + (assoc-in [:activity-center :filter :type] filter-type)) + :dispatch-later [{:ms 25 + :dispatch [:show-popover + {:view :activity-center + :style {:margin 0} + :disable-touchable-overlay? true + :delay-ms 225 + :blur-view? true + :blur-view-props {:blur-amount 20 + :blur-type :dark}}]}]}) ;;;; Misc diff --git a/src/status_im2/contexts/activity_center/events_test.cljs b/src/status_im2/contexts/activity_center/events_test.cljs index 6b5525f118..16bf10be29 100644 --- a/src/status_im2/contexts/activity_center/events_test.cljs +++ b/src/status_im2/contexts/activity_center/events_test.cljs @@ -36,32 +36,23 @@ (deftest open-activity-center-test (testing "opens the activity center with filters enabled" (h/run-test-sync - (let [spy-queue (atom [])] - (setup) - (h/spy-fx spy-queue :show-popover) + (setup) + (rf/dispatch [:activity-center/open + {:filter-type types/contact-request + :filter-status :unread}]) - (rf/dispatch [:activity-center/open - {:filter-type types/contact-request - :filter-status :unread}]) + (is (= {:status :unread + :type types/contact-request} + (get-in (h/db) [:activity-center :filter]))))) - (is (= {:status :unread - :type types/contact-request} - (get-in (h/db) [:activity-center :filter]))) - (is (= [{:id :show-popover :args nil}] - @spy-queue))))) - - (testing "opens the activity center without custom filters" + (testing "opens the activity center with default filters" (h/run-test-sync - (let [spy-queue (atom [])] - (setup) - (h/spy-fx spy-queue :show-popover) + (setup) - (rf/dispatch [:activity-center/open]) + (rf/dispatch [:activity-center/open]) - (is (= {:status :unread :type types/no-type} - (get-in (h/db) [:activity-center :filter]))) - (is (= [{:id :show-popover :args nil}] - @spy-queue)))))) + (is (= {:status :unread :type types/no-type} + (get-in (h/db) [:activity-center :filter])))))) (deftest mark-as-read-test (testing "does nothing if the notification ID cannot be found in the app db"