From 5ecb3fe3d4d55a0a66363798d4e7903b3b4e64b6 Mon Sep 17 00:00:00 2001 From: Gabriel Horner Date: Mon, 3 Jun 2024 14:13:55 -0400 Subject: [PATCH] fix: lints --- deps/db/src/logseq/db/sqlite/build.cljs | 65 +++++++++++++------------ src/main/frontend/rum.cljs | 18 ------- src/main/frontend/ui.cljs | 19 -------- src/resources/dicts/de.edn | 1 - src/resources/dicts/en.edn | 2 - src/resources/dicts/es.edn | 2 - src/resources/dicts/fr.edn | 2 - src/resources/dicts/id.edn | 1 - src/resources/dicts/it.edn | 4 +- src/resources/dicts/ja.edn | 1 - src/resources/dicts/nb-no.edn | 4 +- src/resources/dicts/pt-br.edn | 2 - src/resources/dicts/ru.edn | 1 - src/resources/dicts/sk.edn | 1 - src/resources/dicts/tr.edn | 2 - src/resources/dicts/zh-cn.edn | 1 - 16 files changed, 36 insertions(+), 90 deletions(-) diff --git a/deps/db/src/logseq/db/sqlite/build.cljs b/deps/db/src/logseq/db/sqlite/build.cljs index e73cf089c3..2c064a85a0 100644 --- a/deps/db/src/logseq/db/sqlite/build.cljs +++ b/deps/db/src/logseq/db/sqlite/build.cljs @@ -361,6 +361,36 @@ {:init-tx init-tx :block-props-tx block-props-tx})) +(defn- build-blocks-tx* + [{:keys [pages-and-blocks properties classes graph-namespace] + :as options}] + (let [;; add uuids before tx for refs in :properties + pages-and-blocks' (mapv (fn [{:keys [page blocks]}] + (cond-> {:page (merge {:block/uuid (random-uuid)} page)} + (seq blocks) + (assoc :blocks (mapv #(merge {:block/uuid (random-uuid)} %) blocks)))) + pages-and-blocks) + page-uuids (create-page-uuids pages-and-blocks') + all-idents (create-all-idents properties classes graph-namespace) + properties-tx (build-properties-tx properties page-uuids all-idents) + classes-tx (build-classes-tx classes properties page-uuids all-idents) + class-ident->id (->> classes-tx (map (juxt :db/ident :db/id)) (into {})) + ;; Replace idents with db-ids to avoid any upsert issues + properties-tx' (mapv (fn [m] + (if (:property/schema.classes m) + (update m :property/schema.classes + (fn [cs] + (mapv #(or (some->> (:db/ident %) class-ident->id (hash-map :db/id)) + (throw (ex-info (str "No :db/id found for :db/ident " (pr-str (:db/ident %))) {}))) + cs))) + m)) + properties-tx) + pages-and-blocks-tx (build-pages-and-blocks-tx pages-and-blocks' all-idents page-uuids options)] + ;; Properties first b/c they have schema and are referenced by all. Then classes b/c they can be referenced by pages. Then pages + (split-blocks-tx (concat properties-tx' + classes-tx + pages-and-blocks-tx)))) + (defn build-blocks-tx "Given an EDN map for defining pages, blocks and properties, this creates a map with two keys of transactable data for use with d/transact!. The :init-tx key @@ -368,8 +398,7 @@ The blocks that can be created have the following limitations: * Only top level blocks can be easily defined. Other level blocks can be - defined but they require explicit setting of attributes like :block/order and :block/parent - * Block content containing page refs or tags is not supported yet + defined but they require explicit setting of :block/parent The EDN map has the following keys: @@ -401,35 +430,9 @@ supported: :default, :url, :checkbox, :number, :page and :date. :checkbox and :number values are written as booleans and integers/floats. :page references are written as vectors e.g. `[:page \"PAGE NAME\"]`" - [{:keys [pages-and-blocks properties classes graph-namespace] - :as options}] - (let [_ (validate-options options) - ;; add uuids before tx for refs in :properties - pages-and-blocks' (mapv (fn [{:keys [page blocks]}] - (cond-> {:page (merge {:block/uuid (random-uuid)} page)} - (seq blocks) - (assoc :blocks (mapv #(merge {:block/uuid (random-uuid)} %) blocks)))) - pages-and-blocks) - page-uuids (create-page-uuids pages-and-blocks') - all-idents (create-all-idents properties classes graph-namespace) - properties-tx (build-properties-tx properties page-uuids all-idents) - classes-tx (build-classes-tx classes properties page-uuids all-idents) - class-ident->id (->> classes-tx (map (juxt :db/ident :db/id)) (into {})) - ;; Replace idents with db-ids to avoid any upsert issues - properties-tx' (mapv (fn [m] - (if (:property/schema.classes m) - (update m :property/schema.classes - (fn [cs] - (mapv #(or (some->> (:db/ident %) class-ident->id (hash-map :db/id)) - (throw (ex-info (str "No :db/id found for :db/ident " (pr-str (:db/ident %))) {}))) - cs))) - m)) - properties-tx) - pages-and-blocks-tx (build-pages-and-blocks-tx pages-and-blocks' all-idents page-uuids options)] - ;; Properties first b/c they have schema and are referenced by all. Then classes b/c they can be referenced by pages. Then pages - (split-blocks-tx (concat properties-tx' - classes-tx - pages-and-blocks-tx)))) + [options] + (validate-options options) + (build-blocks-tx* options)) (defn create-blocks "Builds txs with build-blocks-tx and transacts them. Usually used for testing" diff --git a/src/main/frontend/rum.cljs b/src/main/frontend/rum.cljs index 7f2da04b2e..966ec8f204 100644 --- a/src/main/frontend/rum.cljs +++ b/src/main/frontend/rum.cljs @@ -143,24 +143,6 @@ bp (->breakpoint (when (some? rect) (.-width rect)))] [ref bp]))) -(defn use-click-outside - "Returns a function that can be used to register a callback - that will be called when the user clicks outside the given dom node" - [handler & {:keys [capture? event] - :or {capture? false - event "click"}}] ;; could be "mousedown" or "click" - (let [[ref set-ref] (rum/use-state nil)] - (rum/use-effect! - (fn [] - (let [listener (fn [e] - (when (and ref - (not (.. ref (contains (.-target e))))) - (handler e)))] - (js/document.addEventListener event listener capture?) - #(js/document.removeEventListener event listener capture?))) - [ref]) - set-ref)) - (defonce *key->atom (atom {})) (defn cached-derived-atom "Make sure to return the same atom if `key` is the same." diff --git a/src/main/frontend/ui.cljs b/src/main/frontend/ui.cljs index 3c0b5b4ebf..fd97857f88 100644 --- a/src/main/frontend/ui.cljs +++ b/src/main/frontend/ui.cljs @@ -10,7 +10,6 @@ ["emoji-mart" :as emoji-mart] [cljs-bean.core :as bean] [clojure.string :as string] - [datascript.core :as d] [electron.ipc :as ipc] [frontend.components.svg :as svg] [frontend.config :as config] @@ -1160,24 +1159,6 @@ ref (.-ref inViewState)] (lazy-visible-inner visible? content-fn ref fade-in?)))) -(rum/defc portal - ([children] - (portal children {:attach-to (fn [] js/document.body) - :prepend? false})) - ([children {:keys [attach-to prepend?]}] - (let [[portal-anchor set-portal-anchor] (rum/use-state nil)] - (rum/use-effect! - (fn [] - (let [div (js/document.createElement "div") - attached (or (if (fn? attach-to) (attach-to) attach-to) js/document.body)] - (.setAttribute div "data-logseq-portal" (str (d/squuid))) - (if prepend? (.prepend attached div) (.append attached div)) - (set-portal-anchor div) - #(.remove div))) - []) - (when portal-anchor - (rum/portal (rum/fragment children) portal-anchor))))) - (rum/defc menu-heading ([add-heading-fn auto-heading-fn rm-heading-fn] (menu-heading nil add-heading-fn auto-heading-fn rm-heading-fn)) diff --git a/src/resources/dicts/de.edn b/src/resources/dicts/de.edn index afecebfbdc..5289a562e9 100644 --- a/src/resources/dicts/de.edn +++ b/src/resources/dicts/de.edn @@ -409,7 +409,6 @@ :whiteboard/arrow-head "Pfeilspitze" :whiteboard/auto-resize "Automatisch Grösse ändern" :whiteboard/bold "Fett" - :whiteboard/cache-outdated "Der Cache ist veraltet. Klicken Sie auf 'Neu indizieren' im Dropdown-Menu des Graphen." :whiteboard/circle "Kreis" :whiteboard/collapse "Einklappen" :whiteboard/color "Farbe" diff --git a/src/resources/dicts/en.edn b/src/resources/dicts/en.edn index c5cb210baf..b8901eca9b 100644 --- a/src/resources/dicts/en.edn +++ b/src/resources/dicts/en.edn @@ -438,7 +438,6 @@ :whiteboard/new-whiteboard "New whiteboard" :whiteboard/search-only-blocks "Search only blocks" :whiteboard/search-only-pages "Search only pages" - :whiteboard/cache-outdated "Cache is outdated. Please click the 'Re-index' button in the graph's dropdown menu." :whiteboard/shape-quick-links "Shape Quick Links" :whiteboard/edit-pdf "Edit PDF" :whiteboard/dashboard-card-new-whiteboard "New whiteboard" @@ -447,7 +446,6 @@ :whiteboard/toggle-grid "Toggle grid" :whiteboard/snap-to-grid "Snap to grid" :whiteboard/toggle-pen-mode "Toggle pen mode" - :whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Reference" "References")) :flashcards/modal-welcome-title "Time to create a card!" :flashcards/modal-welcome-desc-1 "You can add \"#card\" to any block to turn it into a card or trigger \"/cloze\" to add some clozes." :flashcards/modal-welcome-desc-2 "You can " diff --git a/src/resources/dicts/es.edn b/src/resources/dicts/es.edn index b5c09bb3a9..2364c25b3d 100644 --- a/src/resources/dicts/es.edn +++ b/src/resources/dicts/es.edn @@ -667,7 +667,6 @@ :whiteboard/arrow-head "Cabeza de flecha" :whiteboard/auto-resize "Cambiar tamaño automáticamente" :whiteboard/bold "Negrita" - :whiteboard/cache-outdated "La caché está desactualizada. Por favor da clic en el botón 'Reindexar' en el menú desplegable del grafo." :whiteboard/circle "Círculo" :whiteboard/collapse "Colapsar" :whiteboard/color "Color" @@ -719,7 +718,6 @@ :whiteboard/paste-as-link "Pegar como enlace" :whiteboard/rectangle "Recargar" :whiteboard/redo "Rehacer" - :whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Referencia" "Referencias")) :whiteboard/references "Referencias" :whiteboard/reload "Recargar" :whiteboard/remove-link "Eliminar enlace" diff --git a/src/resources/dicts/fr.edn b/src/resources/dicts/fr.edn index 62acbf51e8..f60b412ee2 100644 --- a/src/resources/dicts/fr.edn +++ b/src/resources/dicts/fr.edn @@ -491,7 +491,6 @@ :whiteboard/color "Couleur" :whiteboard/collapse "Réduire" :whiteboard/circle "Cercle" - :whiteboard/cache-outdated "Le cache n'est plus à jour. Cliquez sur 'Ré-indexer' mais…" :whiteboard/bold "Gras" :whiteboard/auto-resize "Redimensionnement automatique" :whiteboard/arrow-head "Pointe de flèche" @@ -502,7 +501,6 @@ :whiteboard/align-center-horizontally "Aligner horizontalement au centre" :whiteboard/align-bottom "Aligner en bas" :whiteboard/add-block-or-page "Ajouter un bloc ou une page" - :whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Référence" "Références")) :whiteboard/toggle-pen-mode "Activer/désactiver le mode stylet" :tips/all-done "Tout est complété !" :shortcut.category/whiteboard "Tableau blanc" diff --git a/src/resources/dicts/id.edn b/src/resources/dicts/id.edn index 44ebcf6877..de3bb14838 100644 --- a/src/resources/dicts/id.edn +++ b/src/resources/dicts/id.edn @@ -405,7 +405,6 @@ :whiteboard/new-whiteboard "Papan tulis baru" :whiteboard/search-only-blocks "Cari hanya blok" :whiteboard/search-only-pages "Cari hanya halaman" - :whiteboard/cache-outdated "Cache sudah ketinggalan zaman. Klik tombol 'Re-indeks' dalam menu tarik-turun grafik." :whiteboard/shape-quick-links "Tautan Cepat Bentuk" :whiteboard/edit-pdf "Sunting PDF" :whiteboard/dashboard-card-new-whiteboard "Papan tulis baru" diff --git a/src/resources/dicts/it.edn b/src/resources/dicts/it.edn index c1cea59316..c7c73c9381 100644 --- a/src/resources/dicts/it.edn +++ b/src/resources/dicts/it.edn @@ -656,7 +656,6 @@ :whiteboard/arrow-head "Punta della freccia" :whiteboard/auto-resize "Ridimensiona automaticamente" :whiteboard/bold "Grassetto" - :whiteboard/cache-outdated "La cache è obsoleta. Clicca 'Re-indicizza' nel menù a discesa del grafo." :whiteboard/circle "Cerchio" :whiteboard/collapse "Collassa" :whiteboard/color "Colore" @@ -754,5 +753,4 @@ :linked-references/filter-includes "Include: " :linked-references/reference-count (fn [filtered-count total] (str (when filtered-count (str filtered-count " di ")) total (if (= total 1) " Riferimento Collegato" " Riferimenti Collegati"))) :settings-page/git-commit-on-close "Esegui commit Git alla chiusura della finestra" - :unlinked-references/reference-count (fn [total] (str total (if (= total 1) " Riferimento Scollegato" " Riferimenti Scollegati"))) - :whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Riferimento" "Riferimenti"))} + :unlinked-references/reference-count (fn [total] (str total (if (= total 1) " Riferimento Scollegato" " Riferimenti Scollegati")))} diff --git a/src/resources/dicts/ja.edn b/src/resources/dicts/ja.edn index 2e1efcbaac..498d4277bc 100644 --- a/src/resources/dicts/ja.edn +++ b/src/resources/dicts/ja.edn @@ -415,7 +415,6 @@ :whiteboard/new-whiteboard "新しいホワイトボード" :whiteboard/search-only-blocks "ブロックだけを検索" :whiteboard/search-only-pages "ページだけを検索" - :whiteboard/cache-outdated "キャッシュが古くなっています。グラフのドロップダウンメニューにある「インデックス再構築」ボタンをクリックしてください。" :whiteboard/shape-quick-links "図形のクイックリンク" :whiteboard/edit-pdf "PDFを編集" :whiteboard/dashboard-card-new-whiteboard "新しいホワイトボード" diff --git a/src/resources/dicts/nb-no.edn b/src/resources/dicts/nb-no.edn index 865ee11633..b55c5e47ba 100644 --- a/src/resources/dicts/nb-no.edn +++ b/src/resources/dicts/nb-no.edn @@ -491,7 +491,6 @@ :whiteboard/arrow-head "Pilhode" :whiteboard/auto-resize "Automatisk endre størrelse" :whiteboard/bold "Fet" - :whiteboard/cache-outdated "Cache er utdatert. Vennligst klikk 'Re-indekser' knappen" :whiteboard/circle "Sirkel" :whiteboard/collapse "Trekk sammen" :whiteboard/color "Farge" @@ -761,5 +760,4 @@ :linked-references/filter-includes "Inkluderer: " :linked-references/reference-count (fn [filtered-count total] (str (when filtered-count (str filtered-count " av ")) total (if (= total 1) " Lenket Referanse" " Lenkede Referanser"))) :pdf/auto-open-context-menu "Auto-åpne kontekstmeny for valg" - :unlinked-references/reference-count (fn [total] (str total (if (= total 1) " Ulenket Referanse" " Ulenkede Referanser"))) - :whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Referanse" "Referanser"))} + :unlinked-references/reference-count (fn [total] (str total (if (= total 1) " Ulenket Referanse" " Ulenkede Referanser")))} diff --git a/src/resources/dicts/pt-br.edn b/src/resources/dicts/pt-br.edn index 6175546df8..22d932c1e8 100644 --- a/src/resources/dicts/pt-br.edn +++ b/src/resources/dicts/pt-br.edn @@ -409,7 +409,6 @@ :whiteboard/new-whiteboard "Novo whiteboard" :whiteboard/search-only-blocks "Pesquisar apenas blocos" :whiteboard/search-only-pages "Pesquisar apenas páginas" - :whiteboard/cache-outdated "O cache está desatualizado. Clique no botão 'Re-indexar' no menu suspenso do grafo." :whiteboard/shape-quick-links "Links Rápidos de Forma" :whiteboard/edit-pdf "Editar PDF" :whiteboard/dashboard-card-new-whiteboard "Novo whiteboard" @@ -762,7 +761,6 @@ :linked-references/reference-count (fn [filtered-count total] (str (when filtered-count (str filtered-count " de ")) total (if (= total 1) " Referência Vinculada" " Referências Vinculadas"))) :settings-page/git-commit-on-close "Commitar mudanças no Git ao fechar a janela" :unlinked-references/reference-count (fn [total] (str total (if (= total 1) " Referência Não-Vinculada" " Referências Não-Vinculadas"))) - :whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Referência" "Referências")) ;; Allowed duplicates - start :settings-of-plugins "Plugins" diff --git a/src/resources/dicts/ru.edn b/src/resources/dicts/ru.edn index 9deb0c29f4..68143d9885 100644 --- a/src/resources/dicts/ru.edn +++ b/src/resources/dicts/ru.edn @@ -305,7 +305,6 @@ :whiteboard/new-whiteboard "Новая интерактивная доска" :whiteboard/search-only-blocks "Поиск только по блокам" :whiteboard/search-only-pages "Поиск только по страницам" - :whiteboard/cache-outdated "Кэш устарел. Пожалуйста, нажмите кнопку 'Переиндексировать' в выпадающем меню графов." :whiteboard/shape-quick-links "Быстрые ссылки элемента" :home "Домой" :new-page "Новая страница:" diff --git a/src/resources/dicts/sk.edn b/src/resources/dicts/sk.edn index ef5a71ad6f..3b5560b856 100644 --- a/src/resources/dicts/sk.edn +++ b/src/resources/dicts/sk.edn @@ -407,7 +407,6 @@ :whiteboard/new-whiteboard "Nová tabuľa" :whiteboard/search-only-blocks "Vyhľadávať iba bloky" :whiteboard/search-only-pages "Vyhľadávať iba stránky" - :whiteboard/cache-outdated "Cache je zastaraná. Kliknite na tlačidlo 'Preindexovať' v rozbaľovacom menu grafu." :whiteboard/shape-quick-links "Rýchle odkazy na tvary" :whiteboard/edit-pdf "Upraviť PDF" :whiteboard/dashboard-card-new-whiteboard "Nová tabuľa" diff --git a/src/resources/dicts/tr.edn b/src/resources/dicts/tr.edn index dae043ff5d..54ba8d8680 100644 --- a/src/resources/dicts/tr.edn +++ b/src/resources/dicts/tr.edn @@ -434,7 +434,6 @@ :whiteboard/new-whiteboard "Yeni beyaz tahta" :whiteboard/search-only-blocks "Yalnızca blokları ara" :whiteboard/search-only-pages "Yalnızca sayfaları ara" - :whiteboard/cache-outdated "Önbellek eski. Lütfen grafın açılır menüsündeki 'Yeniden dizin oluştur' düğmesini tıklayın." :whiteboard/shape-quick-links "Hızlı Bağlantıları Şekillendir" :whiteboard/edit-pdf "PDF'yi düzenle" :whiteboard/dashboard-card-new-whiteboard "Yeni beyaz tahta" @@ -443,7 +442,6 @@ :whiteboard/toggle-grid "Kılavuzu aç/kapat" :whiteboard/snap-to-grid "Kılavuzlara daya" :whiteboard/toggle-pen-mode "Kalem modunu aç/kapat" - :whiteboard/reference-count (fn [refs-count] (if (= refs-count 1) "Referans" "Referans")) :flashcards/modal-welcome-title "Bir kart oluşturma zamanı!" :flashcards/modal-welcome-desc-1 "Herhangi bir bloğu karta dönüştürmek için \"#card\" etiketini ekleyebilir veya cümle tamamlama eklemek için \"/cloze\" komutunu kullanabilirsiniz." :flashcards/modal-welcome-desc-2 "Belgeleri kontrol etmek için " diff --git a/src/resources/dicts/zh-cn.edn b/src/resources/dicts/zh-cn.edn index ae320c44a9..982f3c22cb 100644 --- a/src/resources/dicts/zh-cn.edn +++ b/src/resources/dicts/zh-cn.edn @@ -409,7 +409,6 @@ :whiteboard/new-whiteboard "新白板:" :whiteboard/search-only-blocks "仅搜索块" :whiteboard/search-only-pages "仅搜索页面" - :whiteboard/cache-outdated "缓存已过期。 请点击图谱下拉菜单中的 '重新建立索引' 按钮重建索引。" :whiteboard/shape-quick-links "形状快速链接" :whiteboard/dashboard-card-new-whiteboard "新建白板" :whiteboard/dashboard-card-created "创建于 "