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.
This commit is contained in:
Icaro Motta 2023-03-03 10:34:55 -03:00 committed by GitHub
parent 8923408972
commit 064204256e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 33 deletions

View File

@ -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

View File

@ -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"