fix: make header reactive on :user-groups and :rtc-running?

This commit is contained in:
rcmerci
2025-04-24 18:08:23 +08:00
parent e78b1afa76
commit e7edd933c7
6 changed files with 26 additions and 15 deletions

View File

@@ -3673,7 +3673,7 @@
(when-not (or in-whiteboard? table? property?) (dnd-separator-wrapper block children block-id slide? false false))]))
(rum/defc ^:large-vars/cleanup-todo block-container-inner
(rum/defc block-container-inner
[container-state repo config* block opts]
(let [container-id (:container-id config*)
block-id (:block/uuid block)

View File

@@ -40,7 +40,7 @@
highlighted-text (string/replace normal-text query-re "<:hlmarker>$1<:hlmarker>")
segs (string/split highlighted-text #"<:hlmarker>")]
(if (seq segs)
(into [:span]
(into [:span {:aria-label text-string}]
(map-indexed (fn [i seg]
(if (even? i)
[:span seg]

View File

@@ -331,10 +331,9 @@
(when (state/sub :ui/toggle-highlight-recent-blocks?)
(recent-slider-inner)))
(rum/defc ^:large-vars/cleanup-todo header < rum/reactive
(rum/defc ^:large-vars/cleanup-todo header-aux < rum/reactive
[{:keys [current-repo default-home new-block-mode]}]
(let [_ (state/sub [:user/info :UserGroups])
electron-mac? (and util/mac? (util/electron?))
(let [electron-mac? (and util/mac? (util/electron?))
left-menu (left-menu-button {:on-click (fn []
(state/set-left-sidebar-open!
(not (:ui/left-sidebar-open? @state/state))))})
@@ -357,13 +356,13 @@
[:div.l.flex.items-center.drag-region
[left-menu
(if (mobile-util/native-platform?)
;; back button for mobile
;; back button for mobile
(when-not (or (state/home?) custom-home-page? (state/whiteboard-dashboard?))
(ui/with-shortcut :go/backward "bottom"
[:button.it.navigation.nav-left.button.icon.opacity-70
{:title (t :header/go-back) :on-click #(js/window.history.back)}
(ui/icon "chevron-left" {:size 26})]))
;; search button for non-mobile
;; search button for non-mobile
(when current-repo
(ui/with-shortcut :go/search "right"
[:button.button.icon#search-button
@@ -421,3 +420,15 @@
(sidebar/toggle)
(updater-tips-new-version t)]]))
(def ^:private header-related-flow
(m/latest
(fn [state rtc-running?]
{:user-groups (get-in state [:user/info :UserGroups])
:rtc-running? rtc-running?})
(m/watch state/state) rtc-flows/rtc-running-flow))
(rum/defc header
[opts]
(let [_m (hooks/use-flow-state header-related-flow)]
(header-aux opts)))

View File

@@ -51,7 +51,7 @@
:local-tx (:local-tx state)
:remote-tx (:remote-tx state)
:rtc-state (if (:rtc-lock state) :open :close)))
rtc-flows/rtc-state-stream-flow)))]
rtc-flows/rtc-state-flow)))]
(reset! *update-detail-info-canceler canceler))))
(run-task--update-detail-info)

View File

@@ -28,8 +28,8 @@
(def rtc-state-flow
(m/watch (:rtc/state @state/state)))
(def rtc-state-stream-flow
(m/stream rtc-state-flow))
(def rtc-running-flow
(m/eduction (map :rtc-lock) rtc-state-flow))
(def rtc-online-users-flow
(c.m/throttle
@@ -40,7 +40,7 @@
(:rtc-lock m))
(:online-users m))))
(dedupe)
rtc-state-stream-flow)))
rtc-state-flow)))
(def ^:private network-online-change-flow
(m/stream
@@ -64,7 +64,7 @@ conditions:
(->> (m/latest
(fn [rtc-state _ login-user]
(assoc rtc-state :login-user login-user))
(c.m/continue-flow rtc-state-stream-flow)
rtc-state-flow
(c.m/continue-flow network-online-change-flow)
flows/current-login-user-flow)
(m/eduction

View File

@@ -467,13 +467,13 @@
(def ^:private create-get-state-flow*
(let [rtc-loop-metadata-flow (m/watch *rtc-loop-metadata)]
(m/ap
(let [{rtc-lock :*rtc-lock
(let [{*rtc-lock' :*rtc-lock
:keys [repo graph-uuid local-graph-schema-version remote-graph-schema-version
user-uuid rtc-state-flow *rtc-auto-push? *rtc-remote-profile?
*online-users *last-stop-exception]}
(m/?< rtc-loop-metadata-flow)]
(try
(when (and repo rtc-state-flow *rtc-auto-push? rtc-lock)
(when (and repo rtc-state-flow *rtc-auto-push? *rtc-lock')
(m/?<
(m/latest
(fn [rtc-state rtc-auto-push? rtc-remote-profile?
@@ -493,7 +493,7 @@
:last-stop-exception-ex-data (some-> *last-stop-exception deref ex-data)})
rtc-state-flow
(m/watch *rtc-auto-push?) (m/watch *rtc-remote-profile?)
(m/watch rtc-lock) (m/watch *online-users)
(m/watch *rtc-lock') (m/watch *online-users)
(client-op/create-pending-block-ops-count-flow repo)
(rtc-log-and-state/create-local-t-flow graph-uuid)
(rtc-log-and-state/create-remote-t-flow graph-uuid))))