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

View File

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