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"