fix: rtc downloading graph indicator

pull/11055/head
Tienson Qin 2024-03-19 12:14:24 +08:00
parent bd7173eaed
commit 7c3a129c3a
1 changed files with 21 additions and 14 deletions

View File

@ -7,7 +7,7 @@
[frontend.util :as util]))
(rum/defc details
[{:keys [unpushed-block-update-count]} uploading?]
[{:keys [unpushed-block-update-count]} uploading? downloading?]
[:div.cp__rtc-sync-details.text-sm.p-1
(cond
uploading?
@ -22,18 +22,25 @@
(let [_ (state/sub :auth/id-token)
online? (state/sub :network/online?)
uploading? (state/sub :rtc/uploading?)
downloading? (state/sub :rtc/downloading-graph-uuid)
{:keys [graph-uuid rtc-state unpushed-block-update-count] :as state}
(state/sub :rtc/state)]
(when graph-uuid
(when (or graph-uuid downloading?)
(if downloading?
(shui/button
{:variant :ghost
:size :sm}
"Downloading...")
[:div.cp__rtc-sync
[:div.cp__rtc-sync-indicator
[:a.button.cloud
{:on-click #(shui/popup-show! (.-target %)
(details state uploading?)
(details state uploading? downloading?)
{:align "end"})
:class (util/classnames [{:on (and online? (= :open rtc-state))
:idle (and online? (= :open rtc-state) (zero? unpushed-block-update-count)
(not uploading?))
:queuing (or uploading? (pos? unpushed-block-update-count))}])}
(not uploading?)
(not downloading?))
:queuing (or uploading? downloading? (pos? unpushed-block-update-count))}])}
[:span.flex.items-center
(ui/icon "cloud" {:size ui/icon-size})]]]])))
(ui/icon "cloud" {:size ui/icon-size})]]]]))))