fix can't enter channel after community is fetched for the first time (#20508)

This commit is contained in:
Parvesh Monu 2024-06-28 16:36:34 +05:30 committed by GitHub
parent 34c95c42d1
commit e92da6d24b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 19 deletions

View File

@ -230,7 +230,7 @@
(when community
{:db (update db :communities/fetching-communities dissoc community-id)
:fx [[:dispatch [:communities/handle-community community]]
[:dispatch [:communities/update-last-opened-at community-id]]
[:dispatch [:chat.ui/spectate-community community-id]]
[:dispatch
[:chat.ui/cache-link-preview-data (link-preview.events/community-link community-id)
community]]]}))
@ -251,7 +251,7 @@
:error err}))
(defn fetch-community
[{:keys [db]} [{:keys [community-id update-last-opened-at?]}]]
[{:keys [db]} [{:keys [community-id]}]]
(when (and community-id
(not (get-in db [:communities community-id]))
(not (get-in db [:communities/fetching-communities community-id])))
@ -262,11 +262,8 @@
:WaitForResponse true}]
:on-success (fn [community]
(if community
(do (when update-last-opened-at?
(rf/dispatch [:communities/update-last-opened-at
community-id]))
(rf/dispatch [:chat.ui/community-fetched community-id
community]))
(rf/dispatch [:chat.ui/community-fetched community-id
community])
(failed-to-fetch-community
community-id
"community wasn't found at the store node")))
@ -280,8 +277,7 @@
[:schema
[:vector
[:map {:closed true}
[:community-id {:optional true} :string]
[:update-last-opened-at? {:optional true} [:maybe :boolean]]]]]]]
[:community-id {:optional true} :string]]]]]]
[:maybe
[:map
[:db map?]
@ -340,10 +336,9 @@
(rf/merge
cofx
{:fx [[:dispatch [:chat.ui/spectate-community community-id]]
[:dispatch [:communities/update-last-opened-at community-id]]
[:dispatch
[:communities/fetch-community
{:community-id community-id
:update-last-opened-at? true}]]
[:communities/fetch-community {:community-id community-id}]]
[:dispatch [:navigate-to :community-overview community-id]]
(when (get-in db [:communities community-id :joined])
[:dispatch
@ -358,10 +353,7 @@
(let [community-id (or community-id (get-in db [:chats chat-id :community-id]))]
(merge
{:fx [(when community-id
[:dispatch
[:communities/fetch-community
{:community-id community-id
:update-last-opened-at? true}]])
[:dispatch [:communities/fetch-community {:community-id community-id}]])
(if pop-to-root?
[:dispatch [:chat/pop-to-root-and-navigate-to-chat chat-id]]
[:dispatch

View File

@ -49,7 +49,7 @@
(testing "dispatch fxs"
(is (match?
{:fx [[:dispatch [:communities/handle-community {:id community-id}]]
[:dispatch [:communities/update-last-opened-at community-id]]
[:dispatch [:chat.ui/spectate-community community-id]]
[:dispatch
[:chat.ui/cache-link-preview-data "community-link+community-id"
{:id community-id}]]]}
@ -60,7 +60,7 @@
(testing "dispatch fxs, do not spectate community"
(is (match?
{:fx [[:dispatch [:communities/handle-community {:id community-id}]]
[:dispatch [:communities/update-last-opened-at community-id]]
[:dispatch [:chat.ui/spectate-community community-id]]
[:dispatch
[:chat.ui/cache-link-preview-data "community-link+community-id"
{:id community-id}]]]}
@ -71,7 +71,7 @@
(testing "dispatch fxs, do not spectate community"
(is (match?
{:fx [[:dispatch [:communities/handle-community {:id community-id}]]
[:dispatch [:communities/update-last-opened-at community-id]]
[:dispatch [:chat.ui/spectate-community community-id]]
[:dispatch
[:chat.ui/cache-link-preview-data "community-link+community-id"
{:id community-id}]]]}