fix: stop shadowing vars for components

Turn on kondo :shadowed-var lint and fix failures.  If this lint had
been turned on, it would have caught logseq/db-test#38 and saved us time
from debugging which random component was accidentally shadowed by a var
and failing with 'Objects are not valid as a React child'. Also fixed a
few outside components but stopped b/c there are too many to do right
now
This commit is contained in:
Gabriel Horner
2024-08-23 15:19:20 -04:00
parent 187fa1d29e
commit 5ff364ba1e
32 changed files with 163 additions and 156 deletions

View File

@@ -3,7 +3,17 @@
:config-in-ns
;; :used-underscored-binding is turned off for components because of false positive
;; for rum/defcs and _state.
{all-components {:linters {:used-underscored-binding {:level :off}}}
{all-components
{:linters {:used-underscored-binding {:level :off}
;; TODO: Apply this to all of frontend
:shadowed-var {:level :warning
;; FIXME: Remove most of these as shadowing core fns isn't a good practice
:exclude [t name binding type uuid key val time fn ex-data list
keys vals sort-by namespace count parents int? hash subs
load-file exists? rest object? min max class array range string? delay?
new var re-pattern update iter ns char resolve sequence identity
dispatch-fn identity comp max-key vec meta next delay str vector list? chars
chunk test]}}}
;; false positive with match/match and _
frontend.handler.paste {:linters {:used-underscored-binding {:level :off}}}
frontend.db {:linters {:aliased-namespace-symbol

View File

@@ -46,8 +46,8 @@
[]
(let [db (db/get-db)
[data set-data!] (rum/use-state (get-all-pages))
columns (views/build-columns {} (columns db)
{:with-object-name? false})
columns' (views/build-columns {} (columns db)
{:with-object-name? false})
view-entity (first (ldb/get-all-pages-views db))]
(rum/use-effect!
(fn []
@@ -61,7 +61,7 @@
(views/view view-entity {:data data
:set-data! set-data!
:title-key :all-pages/table-title
:columns columns
:columns columns'
:on-delete-rows (fn [table selected-rows]
(shui/dialog-open!
(component-page/batch-delete-dialog

View File

@@ -1637,8 +1637,8 @@
(youtube/youtube-video youtube-id nil))))
(= name "youtube-timestamp")
(when-let [timestamp (first arguments)]
(when-let [seconds (youtube/parse-timestamp timestamp)]
(when-let [timestamp' (first arguments)]
(when-let [seconds (youtube/parse-timestamp timestamp')]
(youtube/timestamp seconds)))
(= name "zotero-imported-file")
@@ -2370,12 +2370,12 @@
"Tags without inline tags"
[config block hover?]
(when (:block/raw-title block)
(let [tags (->>
(let [tags' (->>
(:block/tags block)
(remove (fn [t] (ldb/inline-tag? (:block/raw-title block) t))))
block-tags (if (and (not hover?) (= [:logseq.class/Task] (map :db/ident tags)))
(remove (fn [t] (= (:db/ident t) :logseq.class/Task)) tags)
tags)]
block-tags (if (and (not hover?) (= [:logseq.class/Task] (map :db/ident tags')))
(remove (fn [t] (= (:db/ident t) :logseq.class/Task)) tags')
tags')]
(when (seq block-tags)
[:div.block-tags.flex.flex-row.flex-wrap.items-center.gap-1
(for [tag block-tags]
@@ -2504,8 +2504,8 @@
nil)]]))
(rum/defc block-refs-count < rum/static
[block block-refs-count *hide-block-refs?]
(when (> block-refs-count 0)
[block block-refs-count' *hide-block-refs?]
(when (> block-refs-count' 0)
(shui/button {:variant :ghost
:title "Open block references"
:class "px-2 py-0 w-6 h-6 opacity-70 hover:opacity-100"
@@ -2517,7 +2517,7 @@
(:db/id block)
:block-ref)
(swap! *hide-block-refs? not)))}
[:span.text-sm block-refs-count])))
[:span.text-sm block-refs-count'])))
(rum/defc block-left-menu < rum/reactive
[_config {:block/keys [uuid] :as _block}]
@@ -2747,7 +2747,7 @@
(if (seq ast-title)
(->elem :span.inline-wrap (map-inline config ast-title))
(->elem :div (markup-elements-cp config ast-body))))]))))
breadcrumb (->> (into [] parents-props)
breadcrumbs (->> (into [] parents-props)
(concat [page-name-props] (when more? [:more]))
(filterv identity)
(map (fn [x]
@@ -2756,9 +2756,9 @@
(rum/with-key (breadcrumb-fragment config block label opts) (:block/uuid block)))
[:span.opacity-70 "⋯"])))
(interpose (breadcrumb-separator)))]
(when (seq breadcrumb)
(when (seq breadcrumbs)
[:div.breadcrumb.block-parents
{:class (when (seq breadcrumb)
{:class (when (seq breadcrumbs)
(str (when-not (:search? config)
" my-2")
(when indent?
@@ -2766,11 +2766,11 @@
(when (and (false? (:top-level? config))
(seq parents))
(breadcrumb-separator))
breadcrumb
breadcrumbs
(when end-separator? (breadcrumb-separator))]))))))
(defn- block-drag-over
[event uuid top? block-id *move-to]
[event uuid top? block-id *move-to']
(util/stop event)
(when-not (dnd-same-block? uuid)
(let [over-block (gdom/getElement block-id)
@@ -2789,25 +2789,25 @@
:else
:sibling)]
(reset! *drag-to-block block-id)
(reset! *move-to move-to-value))))
(reset! *move-to' move-to-value))))
(defn- block-drag-leave
[*move-to]
(reset! *move-to nil))
[*move-to']
(reset! *move-to' nil))
(defn block-drag-end
([_event]
(block-drag-end _event *move-to))
([_event *move-to]
([_event *move-to']
(reset! *dragging? false)
(reset! *dragging-block nil)
(reset! *drag-to-block nil)
(reset! *move-to nil)
(reset! *move-to' nil)
(editor-handler/unhighlight-blocks!)))
(defn- block-drop
"Block on-drop handler"
[^js event uuid target-block original-block *move-to]
[^js event uuid target-block original-block *move-to']
(util/stop event)
(when-not (dnd-same-block? uuid)
(let [block-uuids (state/get-selection-block-ids)
@@ -2817,7 +2817,7 @@
blocks (remove-nils blocks)]
(if (seq blocks)
;; dnd block moving in current Logseq instance
(dnd/move-blocks event blocks target-block original-block @*move-to)
(dnd/move-blocks event blocks target-block original-block @*move-to')
;; handle DataTransfer
(let [repo (state/get-current-repo)
data-transfer (.-dataTransfer event)
@@ -2829,8 +2829,8 @@
text
{:block-uuid uuid
:edit-block? false
:sibling? (= @*move-to :sibling)
:before? (= @*move-to :top)}))
:sibling? (= @*move-to' :sibling)
:before? (= @*move-to' :top)}))
(contains? transfer-types "Files")
(let [files (.-files data-transfer)
@@ -2862,7 +2862,7 @@
:else
(prn ::unhandled-drop-data-transfer-type transfer-types))))))
(block-drag-end event *move-to))
(block-drag-end event *move-to'))
(defn- block-mouse-over
[e *control-show? block-id doc-mode?]
@@ -2893,15 +2893,15 @@
(state/into-selection-mode!)))
(defn- on-drag-and-mouse-attrs
[block original-block uuid top? block-id *move-to]
[block original-block uuid top? block-id *move-to']
{:on-drag-over (fn [event]
(block-drag-over event uuid top? block-id *move-to))
(block-drag-over event uuid top? block-id *move-to'))
:on-drag-leave (fn [_event]
(block-drag-leave *move-to))
(block-drag-leave *move-to'))
:on-drop (fn [event]
(block-drop event uuid block original-block *move-to))
(block-drop event uuid block original-block *move-to'))
:on-drag-end (fn [event]
(block-drag-end event *move-to))})
(block-drag-end event *move-to'))})
(defn- root-block?
[config block]

View File

@@ -86,8 +86,8 @@
(let [sidebar? (:sidebar? (last (:rum/args state)))
results @(::results state)
input @(::input state)
filter @(::filter state)
filter-group (:group filter)
filter' @(::filter state)
filter-group (:group filter')
index (volatile! -1)
visible-items (fn [group]
(let [{:keys [items show]} (get results group)]
@@ -556,7 +556,7 @@
highlighted-item (or @(::highlighted-item state) first-item)
highlighted-group @(::highlighted-group state)
*mouse-active? (::mouse-active? state')
filter @(::filter state)
filter' @(::filter state)
can-show-less? (< GROUP-LIMIT (count visible-items))
can-show-more? (< (count visible-items) (count items))
show-less #(swap! (::results state) assoc-in [group :show] :less)
@@ -586,7 +586,7 @@
(when (and (= group highlighted-group)
(or can-show-more? can-show-less?)
(empty? filter)
(empty? filter')
(not sidebar?))
[:a.text-link.select-node.opacity-50.hover:opacity-90
{:on-click (if (= show :more) show-less show-more)}
@@ -737,11 +737,11 @@
(and enter? (not composing?)) (do
(handle-action :default state e)
(util/stop-propagation e))
esc? (let [filter @(::filter state)]
esc? (let [filter' @(::filter state)]
(when-not (string/blank? input)
(util/stop e)
(handle-input-change state nil ""))
(when (and filter (string/blank? input))
(when (and filter' (string/blank? input))
(util/stop e)
(reset! (::filter state) nil)
(load-results :default state)))
@@ -830,9 +830,9 @@
{:init (fn [state]
(assoc state ::rand-tip (rand-tip)))}
[inner-state state]
(let [filter @(::filter state)]
(let [filter' @(::filter state)]
(cond
filter
filter'
[:div.flex.flex-row.gap-1.items-center.opacity-50.hover:opacity-100
[:div "Type"]
(shui/shortcut "esc" {:tiled false})

View File

@@ -167,16 +167,16 @@
(rfe/push-state :page {:name "Favorites"})
(util/stop e))}
(when (seq favorite-entities)
(let [favorites (map
(fn [e]
(let [icon (icon/get-node-icon e {})]
{:id (str (:db/id e))
:value (:block/uuid e)
:content [:li.favorite-item (page-name e icon false)]}))
favorite-entities)]
(dnd-component/items favorites
{:on-drag-end (fn [favorites]
(page-handler/<reorder-favorites! favorites))
(let [favorite-items (map
(fn [e]
(let [icon (icon/get-node-icon e {})]
{:id (str (:db/id e))
:value (:block/uuid e)
:content [:li.favorite-item (page-name e icon false)]}))
favorite-entities)]
(dnd-component/items favorite-items
{:on-drag-end (fn [favorites']
(page-handler/<reorder-favorites! favorites'))
:parent-node :ul.favorites.text-sm}))))))
(rum/defc recent-pages < rum/reactive db-mixins/query
@@ -845,7 +845,7 @@
(mixins/listen state js/window "keyup"
(fn [_e]
(state/set-state! :editor/latest-shortcut nil)))))
[state route-match main-content]
[state route-match main-content']
(let [{:keys [open-fn]} state
current-repo (state/sub :git/current-repo)
granted? (state/sub [:nfs/user-granted? (state/get-current-repo)])
@@ -939,7 +939,7 @@
:indexeddb-support? indexeddb-support?
:light? light?
:db-restoring? db-restoring?
:main-content main-content
:main-content main-content'
:show-action-bar? show-action-bar?
:show-recording-bar? show-recording-bar?})]

View File

@@ -454,7 +454,6 @@
[state id {:keys [format
config
hiccup
content
on-click
on-hide]
:as option}]
@@ -463,4 +462,4 @@
(hiccup-content id option)]
;; TODO: remove this
(let [format (common-util/normalize-format format)]
(non-hiccup-content id content on-click on-hide config format))))
(non-hiccup-content id (:content option) on-click on-hide config format))))

View File

@@ -39,7 +39,7 @@
(let [ids (mapv :id col)
items' (bean/->js ids)
id->item (zipmap ids col)
[items set-items] (rum/use-state items')
[items-state set-items] (rum/use-state items')
_ (rum/use-effect! (fn [] (set-items items')) [col])
[_active-id set-active-id] (rum/use-state nil)
sensors (useSensors (useSensor PointerSensor (bean/->js {:activationConstraint {:distance 8}})))
@@ -55,7 +55,7 @@
(when-not (= active-id over-id)
(let [old-index (.indexOf ids active-id)
new-index (.indexOf ids over-id)
new-items (arrayMove items old-index new-index)]
new-items (arrayMove items-state old-index new-index)]
(when (fn? on-drag-end)
(let [new-values (->> (map (fn [id]
(let [item (id->item id)]
@@ -66,7 +66,7 @@
(if (not= (count new-values) (count ids))
(do
(js/console.error "Dnd length not matched: ")
{:old-items items
{:old-items items-state
:new-items new-items})
(do
(set-items new-items)
@@ -76,7 +76,7 @@
:down
:up)}))))))))
(set-active-id nil)))}
sortable-opts {:items items
sortable-opts {:items items-state
:strategy (if vertical?
verticalListSortingStrategy
horizontalListSortingStrategy)}

View File

@@ -501,11 +501,11 @@
{:not-matched-handler (editor-handler/keydown-not-matched-handler format)}))
(defn- set-up-key-up!
[state input input-id]
[state input' input-id]
(mixins/on-key-up
state
{}
(editor-handler/keyup-handler state input input-id)))
(editor-handler/keyup-handler state input' input-id)))
(def search-timeout (atom nil))
@@ -513,9 +513,9 @@
[state]
(let [{:keys [id format]} (get-state)
input-id id
input (gdom/getElement input-id)]
input' (gdom/getElement input-id)]
(set-up-key-down! state format)
(set-up-key-up! state input input-id)))
(set-up-key-up! state input' input-id)))
(defn get-editor-style-class
"Get textarea css class according to it's content"

View File

@@ -21,14 +21,14 @@
(defonce emojis (vals (bean/->clj (gobj/get emoji-data "emojis"))))
(defn icon
[icon & [opts]]
[icon' & [opts]]
(cond
(and (= :emoji (:type icon)) (:id icon))
[:em-emoji (merge {:id (:id icon)}
(and (= :emoji (:type icon')) (:id icon'))
[:em-emoji (merge {:id (:id icon')}
opts)]
(and (= :tabler-icon (:type icon)) (:id icon))
(ui/icon (:id icon) opts)))
(and (= :tabler-icon (:type icon')) (:id icon'))
(ui/icon (:id icon') opts)))
(defn get-node-icon
[node-entity opts]
@@ -76,9 +76,9 @@
(defn- search
[q tab]
(p/let [icons (when (not= tab :emoji) (search-tabler-icons q))
emojis (when (not= tab :icon) (search-emojis q))]
emojis' (when (not= tab :icon) (search-emojis q))]
{:icons icons
:emojis emojis}))
:emojis emojis'}))
(rum/defc icons-row
[items]
@@ -136,38 +136,38 @@
[:em-emoji {:id id}]])
(rum/defc emojis-cp < rum/static
[emojis {:keys [searching?] :as opts}]
[emojis' {:keys [searching?] :as opts}]
(pane-section
(util/format "Emojis (%s)" (count emojis))
(for [emoji emojis]
(util/format "Emojis (%s)" (count emojis'))
(for [emoji emojis']
(rum/with-key (emoji-cp emoji opts) (:id emoji)))
{:virtual-list? true
:searching? searching?}))
(rum/defc icon-cp < rum/static
[icon {:keys [on-chosen hover]}]
[icon' {:keys [on-chosen hover]}]
[:button.w-9.h-9.transition-opacity
(when-let [icon (cond-> icon (string? icon) (string/replace " " ""))]
{:key icon
(when-let [icon' (cond-> icon' (string? icon') (string/replace " " ""))]
{:key icon'
:tabIndex "0"
:title icon
:title icon'
:on-click (fn [e]
(on-chosen e {:type :tabler-icon
:id icon
:name icon}))
:id icon'
:name icon'}))
:on-mouse-over #(reset! hover {:type :tabler-icon
:id icon
:name icon
:icon icon})
:id icon'
:name icon'
:icon icon'})
:on-mouse-out #()})
(ui/icon icon {:size 24})])
(ui/icon icon' {:size 24})])
(rum/defc icons-cp < rum/static
[icons {:keys [searching?] :as opts}]
(pane-section
(util/format "Icons (%s)" (count icons))
(for [icon icons]
(icon-cp icon opts))
(for [icon' icons]
(icon-cp icon' opts))
{:virtual-list? true
:searching? searching?}))

View File

@@ -13,7 +13,7 @@
[page]
[:div.journal-item.content {:key (:db/id page)}
(let [repo (state/sub :git/current-repo)]
(page/page {:repo repo
(page/page-cp {:repo repo
:page-name (str (:block/uuid page))}))])
(defn on-scroll

View File

@@ -32,10 +32,10 @@
(reset! loaded? true))))
state)}
[config id attr code options]
(let [loaded? (rum/react loaded?)
(let [loaded?' (rum/react loaded?)
theme (state/sub :ui/theme)
code (or code "")
code (string/replace-first code #"\n$" "")] ;; See-also: #3410
(if loaded?
(if loaded?'
(@lazy-editor config id attr code theme options)
(ui/loading "CodeMirror"))))

View File

@@ -104,7 +104,7 @@
:sidebar? sidebar?})
(str (:block/uuid page-e) "-hiccup"))])))
(declare page)
(declare page-cp)
(if config/publishing?
(rum/defc dummy-block
@@ -245,7 +245,7 @@
(query/custom-query (component-block/wrap-query-components
{:attr {:class "mt-10"}
:editor-box editor/box
:page page})
:page page-cp})
query))
(str repo "-custom-query-" (:query query))))]))))
@@ -653,7 +653,7 @@
[state option]
(page-inner (assoc option :*loading? (::loading? state))))
(rum/defcs page
(rum/defcs page-cp
[state option]
(rum/with-key
(page-aux option)

View File

@@ -802,8 +802,7 @@
(rum/local 1 ::current-page)
[state]
(let [*list-node-ref (rum/create-ref)
installed-plugins (state/sub [:plugin/installed-plugins])
installed-plugins (vals installed-plugins)
installed-plugins' (vals (state/sub [:plugin/installed-plugins]))
updating (state/sub :plugin/installing)
develop-mode? (state/sub :ui/developer-mode?)
selected-unpacked-pkg (state/sub :plugin/selected-unpacked-pkg)
@@ -816,9 +815,9 @@
*cached-query-flag (::cached-query-flag state)
*current-page (::current-page state)
default-filter-by? (= :default @*filter-by)
theme-plugins (filter #(:theme %) installed-plugins)
normal-plugins (filter #(not (:theme %)) installed-plugins)
filtered-plugins (when (seq installed-plugins)
theme-plugins (filter #(:theme %) installed-plugins')
normal-plugins (filter #(not (:theme %)) installed-plugins')
filtered-plugins (when (seq installed-plugins')
(if (= @*category :themes) theme-plugins normal-plugins))
total-nums [(count normal-plugins) (count theme-plugins)]
filtered-plugins (if-not default-filter-by?

View File

@@ -200,15 +200,15 @@
dropdown-opts {:modal-class (util/hiccup->class
"origin-top-right.absolute.left-0.rounded-md.shadow-lg")}]
[:div.closed-values.flex.flex-col
(let [choices (doall
(keep (fn [value]
(when-let [block (db/sub-block (:db/id value))]
(let [id (:block/uuid block)]
{:id (str id)
:value id
:content (choice-item-content property block (merge opts dropdown-opts))})))
values))]
(dnd/items choices
(let [choice-items (doall
(keep (fn [value]
(when-let [block (db/sub-block (:db/id value))]
(let [id (:block/uuid block)]
{:id (str id)
:value id
:content (choice-item-content property block (merge opts dropdown-opts))})))
values))]
(dnd/items choice-items
{:on-drag-end (fn [_ {:keys [active-id over-id direction]}]
(let [move-down? (= direction :down)
over (db/entity [:block/uuid (uuid over-id)])

View File

@@ -767,7 +767,7 @@
editing? (or editing?
(and (state/sub-editing? [container-id (:block/uuid block)])
(= (:db/id property) (:db/id (:property (state/get-editor-action-data))))))
select-type? (select-type? property type)
select-type?' (select-type? property type)
closed-values? (seq (:property/closed-values property))
select-opts {:on-chosen on-chosen}
value (if (and (de/entity? value*) (= (:db/ident value*) :logseq.property/empty-placeholder))
@@ -775,7 +775,7 @@
value*)]
(if (= :logseq.property/icon (:db/ident property))
(icon-row block)
(if (and select-type?
(if (and select-type?'
(not (and (not closed-values?) (= type :date))))
(single-value-select block property value
(fn [] (select-item property type value opts))

View File

@@ -290,7 +290,7 @@
[_popup-id property opts]
(let [title (:block/title property)
property-type (get-in property [:block/schema :type])
property-type-label (some-> property-type (property-type-label))
property-type-label' (some-> property-type (property-type-label))
enable-closed-values? (contains? db-property-type/closed-value-property-types
(or property-type :default))
icon (:logseq.property/icon property)
@@ -301,7 +301,7 @@
[:<>
(dropdown-editor-menuitem {:icon :edit :title "Property name" :desc [:span.flex.items-center.gap-1 icon title]
:submenu-content (fn [ops] (name-edit-pane property (assoc ops :disabled? disabled?)))})
(dropdown-editor-menuitem {:icon :hash :title "Property type" :desc (str property-type-label) :disabled? true})
(dropdown-editor-menuitem {:icon :hash :title "Property type" :desc (str property-type-label') :disabled? true})
(when enable-closed-values? (empty? (:property/schema.classes property))
(let [values (:property/closed-values property)]

View File

@@ -449,16 +449,16 @@
"origin-top-right.absolute.left-0.mt-2.ml-2.rounded-md.shadow-lg.w-64")}))
(rum/defc clause
[*tree *find loc clause]
(when (seq clause)
[*tree *find loc clauses]
(when (seq clauses)
[:div.query-builder-clause
(let [kind (keyword (first clause))]
(let [kind (keyword (first clauses))]
(if (query-builder/operators-set kind)
[:div.operator-clause.flex.flex-row.items-center {:data-level (count loc)}
[:div.clause-bracket "("]
(clauses-group *tree *find (conj loc 0) kind (rest clause))
(clauses-group *tree *find (conj loc 0) kind (rest clauses))
[:div.clause-bracket ")"]]
(clause-inner *tree loc clause)))]))
(clause-inner *tree loc clauses)))]))
(rum/defc clauses-group
[*tree *find loc kind clauses]

View File

@@ -219,11 +219,11 @@
(rum/defcs result-table-v1 < rum/reactive
(rum/local false ::select?)
(rum/local false ::mouse-down?)
[state config current-block sort-result sort-state columns {:keys [page?]} map-inline page-cp ->elem inline-text]
[state config current-block sort-result' sort-state columns {:keys [page?]} map-inline page-cp ->elem inline-text]
(let [select? (get state ::select?)
*mouse-down? (::mouse-down? state)
clock-time-total (when-not page?
(->> (map #(get-in % [:block/properties :clock-time] 0) sort-result)
(->> (map #(get-in % [:block/properties :clock-time] 0) sort-result')
(apply +)))
property-separated-by-commas? (partial text/separated-by-commas? (state/get-config))
db-graph? (config/db-based-graph? (state/get-current-repo))
@@ -243,7 +243,7 @@
(name column)))]
(sortable-title title column sort-state (:block/uuid current-block) {:db-graph? db-graph?})))]]
[:tbody
(for [row sort-result]
(for [row sort-result']
(let [format (:block/format row)]
[:tr.cursor
(for [column columns]
@@ -297,5 +297,5 @@
;; Sort state needs to be in sync between final result and sortable title
;; as user needs to know if there result is sorted
sort-state (get-sort-state current-block {:db-graph? db-graph?})
sort-result (sort-result result' (assoc sort-state :page? page? :db-graph? db-graph?))]
(result-table-v1 config current-block sort-result sort-state columns options map-inline page-cp ->elem inline-text))))
sort-result' (sort-result result' (assoc sort-state :page? page? :db-graph? db-graph?))]
(result-table-v1 config current-block sort-result' sort-state columns options map-inline page-cp ->elem inline-text))))

View File

@@ -144,7 +144,7 @@
(unlink-or-remote-fn!))))}
(if only-cloud? "Remove (server)" "Unlink (local)")]))]]]))
(rum/defc repos < rum/reactive
(rum/defc repos-cp < rum/reactive
[]
(let [login? (boolean (state/sub :auth/id-token))
repos (state/sub [:me :repos])

View File

@@ -37,22 +37,22 @@
(rum/defc block-cp < rum/reactive
[repo idx block]
(let [id (:block/uuid block)]
(page/page {:parameters {:path {:name (str id)}}
(page/page-cp {:parameters {:path {:name (str id)}}
:sidebar? true
:sidebar/idx idx
:repo repo})))
(rum/defc page-cp < rum/reactive
[repo page-name]
(page/page {:parameters {:path {:name page-name}}
(page/page-cp {:parameters {:path {:name page-name}}
:sidebar? true
:repo repo}))
(rum/defc contents < rum/reactive db-mixins/query
[]
[:div.contents.flex-col.flex.ml-3
(when-let [contents (db/get-page "contents")]
(page/contents-page contents))])
(when-let [contents-page (db/get-page "contents")]
(page/contents-page contents-page))])
(rum/defc shortcut-settings
[]

View File

@@ -108,19 +108,19 @@
(let [detail-info (rum/react *detail-info)
_ (state/sub :auth/id-token)
online? (state/sub :network/online?)
uploading? (uploading? detail-info)
downloading? (downloading? detail-info)
uploading?' (uploading? detail-info)
downloading?' (downloading? detail-info)
rtc-state (:rtc-state detail-info)
unpushed-block-update-count (:pending-local-ops detail-info)]
[:div.cp__rtc-sync
[:div.cp__rtc-sync-indicator.flex.flex-row.items-center.gap-1
(when downloading?
(when downloading?'
(shui/button
{:class "opacity-50"
:variant :ghost
:size :sm}
"Downloading..."))
(when uploading?
(when uploading?'
(shui/button
{:class "opacity-50"
:variant :ghost

View File

@@ -29,7 +29,7 @@
[frontend.storage :as storage]
[frontend.ui :as ui]
[frontend.util :refer [classnames web-platform?] :as util]
[frontend.version :refer [version]]
[frontend.version :as fv]
[goog.object :as gobj]
[goog.string :as gstring]
[promesa.core :as p]
@@ -718,7 +718,7 @@
(let [preferred-language (state/sub [:preferred-language])
show-radix-themes? true]
[:div.panel-wrap.is-general
(version-row t version)
(version-row t fv/version)
(language-row t preferred-language)
(theme-modes-row t)
(when (and (util/electron?) (not util/mac?)) (native-titlebar-row t))

View File

@@ -86,13 +86,13 @@
(LSAuthenticator
{:termsLink "https://blog.logseq.com/terms/"}
(fn [^js op]
(let [sign-out! (.-signOut op)
(let [sign-out!' (.-signOut op)
^js user-proxy (.-user op)
^js user (try (js/JSON.parse (js/JSON.stringify user-proxy))
(catch js/Error e
(js/console.error "Error: Amplify user payload:" e)))
user' (bean/->clj user)]
(user-pane sign-out! user')))))]))
(user-pane sign-out!' user')))))]))
(rum/defcs modal-inner <
shortcut/disable-all-shortcuts

View File

@@ -734,8 +734,8 @@
(when (seq filters)
[:div.filters-row.flex.flex-row.items-center.gap-4.flex-wrap.pb-2
(map-indexed
(fn [idx filter]
(let [[property-ident operator value] filter
(fn [idx filter']
(let [[property-ident operator value] filter'
property (if (= property-ident :block/title)
{:db/ident property-ident
:block/title "Name"}
@@ -757,7 +757,7 @@
:variant "ghost"
:size :sm
:on-click (fn [_e]
(let [new-filters (vec (remove #{filter} filters))]
(let [new-filters (vec (remove #{filter'} filters))]
(set-filters! new-filters)))}
(ui/icon "x"))]))
filters)])))

View File

@@ -162,17 +162,17 @@
([s] (ext-of-video? s true))
([s html5?]
(when-let [s (and (string? s) (util/get-file-ext s))]
(let [video-formats (cond-> video-formats
html5? (disj :mkv))]
(extname-of-supported? s [video-formats])))))
(let [video-formats' (cond-> video-formats
html5? (disj :mkv))]
(extname-of-supported? s [video-formats'])))))
(defn ext-of-audio?
([s] (ext-of-audio? s true))
([s html5?]
(when-let [s (and (string? s) (util/get-file-ext s))]
(let [audio-formats (cond-> audio-formats
html5? (disj :wma :ogg))]
(extname-of-supported? s [audio-formats])))))
(let [audio-formats' (cond-> audio-formats
html5? (disj :wma :ogg))]
(extname-of-supported? s [audio-formats'])))))
(defn ext-of-image?
[s]

View File

@@ -613,7 +613,6 @@ independent of format as format specific heading characters are stripped"
(when repo
(when (conn/get-db repo)
(let [entity (db-utils/entity eid)
page? (ldb/page? entity)
ids (page-alias-set repo eid)]
(->>
(react/q repo

View File

@@ -661,10 +661,10 @@ Some bindings in this fn:
(query repo query-string {}))
([repo query-string query-opts]
(when (and (string? query-string) (not= "\"\"" query-string))
(let [{:keys [query rules sort-by blocks? sample]} (parse-query query-string)]
(when-let [query' (some-> query (query-wrapper {:blocks? blocks?
:block-attrs (when (config/db-based-graph? repo)
db-block-attrs)}))]
(let [{query* :query :keys [rules sort-by blocks? sample]} (parse-query query-string)]
(when-let [query' (some-> query* (query-wrapper {:blocks? blocks?
:block-attrs (when (config/db-based-graph? repo)
db-block-attrs)}))]
(let [random-samples (if @sample
(fn [col]
(take @sample (shuffle col)))
@@ -690,9 +690,9 @@ Some bindings in this fn:
(when (seq (:query query-m))
(let [query-string (template/resolve-dynamic-template! (pr-str (:query query-m)))
db-graph? (config/db-based-graph? repo)
{:keys [query sort-by blocks? rules]} (parse query-string {:db-graph? db-graph?})]
(when-let [query' (some-> query (query-wrapper {:blocks? blocks?
:block-attrs (when db-graph? db-block-attrs)}))]
{query* :query :keys [sort-by blocks? rules]} (parse query-string {:db-graph? db-graph?})]
(when-let [query' (some-> query* (query-wrapper {:blocks? blocks?
:block-attrs (when db-graph? db-block-attrs)}))]
(query-react/react-query repo
(merge
query-m

View File

@@ -36,7 +36,7 @@
(rum/defc page-cp
[props]
(page/page {:page-name (gobj/get props "pageName") :whiteboard? true}))
(page/page-cp {:page-name (gobj/get props "pageName") :whiteboard? true}))
(rum/defc block-cp
[props]

View File

@@ -130,7 +130,7 @@
(defn- register-components-fns!
[]
(state/set-page-blocks-cp! page/page)
(state/set-page-blocks-cp! page/page-cp)
(state/set-component! :block/linked-references reference/block-linked-references)
(state/set-component! :whiteboard/tldraw-preview whiteboard/tldraw-preview)
(state/set-component! :block/single-block block/single-block-cp)

View File

@@ -87,7 +87,7 @@
(defn- register-components-fns!
[]
(state/set-page-blocks-cp! page-component/page)
(state/set-page-blocks-cp! page-component/page-cp)
(state/set-component! :block/linked-references reference/block-linked-references)
(state/set-component! :whiteboard/tldraw-preview whiteboard/tldraw-preview)
(state/set-component! :block/single-block block/single-block-cp)

View File

@@ -27,7 +27,7 @@
["/graphs"
{:name :graphs
:view repo/repos}]
:view repo/repos-cp}]
["/whiteboards"
{:name :whiteboards
@@ -40,11 +40,11 @@
whiteboard? (ldb/whiteboard? (db/get-page page-name))]
(if whiteboard?
(whiteboard/whiteboard-route route-match)
(page/page route-match))))}]
(page/page-cp route-match))))}]
["/page/:name/block/:block-route-name"
{:name :page-block
:view page/page}]
:view page/page-cp}]
["/all-pages"
{:name :all-pages

View File

@@ -13,7 +13,7 @@
unlinked-refs? (some-> props1 :include-unlinked-refs)
config (some-> props1 (dissoc :page :include-linked-refs :include-unlinked-refs))]
(when-let [_entity (page/get-page-entity page-name)]
(page/page
(page/page-cp
{:repo (state/get-current-repo)
:page-name page-name
:preview? false