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