fix: Community state cannot be changed to failed to fetch (#20101)

Signed-off-by: yqrashawn <namy.19@gmail.com>
This commit is contained in:
yqrashawn 2024-05-21 09:16:05 +08:00 committed by GitHub
parent 389a730eff
commit b358c06a31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 8 deletions

View File

@ -241,6 +241,13 @@
(rf/reg-event-fx :chat.ui/community-failed-to-fetch community-failed-to-fetch)
(defn- failed-to-fetch-community
[community-id err]
(rf/dispatch [:chat.ui/community-failed-to-fetch community-id])
(log/error {:message
"Failed to request community info from mailserver"
:error err}))
(defn fetch-community
[{:keys [db]} [{:keys [community-id update-last-opened-at?]}]]
(when (and community-id (not (get-in db [:communities/fetching-communities community-id])))
@ -250,14 +257,16 @@
:TryDatabase true
:WaitForResponse true}]
:on-success (fn [community]
(when update-last-opened-at?
(rf/dispatch [:communities/update-last-opened-at community-id]))
(rf/dispatch [:chat.ui/community-fetched community-id community]))
:on-error (fn [err]
(rf/dispatch [:chat.ui/community-failed-to-fetch community-id])
(log/error {:message
"Failed to request community info from mailserver"
:error err}))}]}))
(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]))
(failed-to-fetch-community
community-id
"community wasn't found at the store node")))
:on-error (partial failed-to-fetch-community community-id)}]}))
(schema/=> fetch-community
[:=>