fix: lint

This commit is contained in:
Tienson Qin
2023-06-28 15:20:03 +08:00
parent f06539ae34
commit c81e114a1c
45 changed files with 165 additions and 252 deletions

View File

@@ -85,3 +85,6 @@ frontend.fs.sync/debug-print-sync-events-loop
frontend.fs.sync/stop-debug-print-sync-events-loop
;; Used in macro
frontend.state/get-current-edit-block-and-position
;; Temporal
frontend.handler.property/delete-property!
frontend.handler.property/delete-property-value!

0
.clj-kondo/.lock Normal file
View File

View File

@@ -21,6 +21,10 @@
goog.string.unescapeEntities
;; TODO:lint: Fix when fixing all type hints
object]}
:unused-namespace {:level :warning
:exclude [frontend.db.datascript.entity-plus]}
;; TODO:lint: Remove node-path excludes once we have a cleaner api
:unresolved-var {:exclude [frontend.util/node-path.basename
frontend.util/node-path.dirname

View File

@@ -34,9 +34,6 @@
;; Enable showing the body of blocks when referencing them.
:ui/show-full-blocks? false
;; Enable Block timestamp
:feature/enable-block-timestamps? false
;; Enable remove accents when searching.
;; After toggle this option, please remember to rebuild your search index by press (cmd+c cmd+s).
:feature/enable-search-remove-accents? true
@@ -344,5 +341,3 @@
;; specify the format of the filename for journal files
;; :journal/file-name-format "yyyy_MM_dd"

View File

@@ -219,9 +219,78 @@
(when-let [win @*win]
(open-url-handler win url))))))
(defn- on-app-ready!
[^js app]
(.on app "ready"
(fn []
(let [t0 (setup-interceptor! app)
^js win (win/create-main-window!)
_ (reset! *win win)]
(logger/info (str "Logseq App(" (.getVersion app) ") Starting... "))
(utils/<restore-proxy-settings)
(js-utils/disableXFrameOptions win)
(search/ensure-search-dir!)
(db/ensure-graphs-dir!)
(search/open-dbs!)
(git/auto-commit-current-graph!)
(vreset! *setup-fn
(fn []
(let [t1 (setup-updater! win)
t2 (setup-app-manager! win)
t3 (handler/set-ipc-handler! win)
t4 (server/setup! win)
tt (exceptions/setup-exception-listeners!)]
(vreset! *teardown-fn
#(doseq [f [t0 t1 t2 t3 t4 tt]]
(and f (f)))))))
;; setup effects
(@*setup-fn)
;; main window events
;; TODO merge with window/on-close-actions!
;; TODO elimilate the difference between main and non-main windows
(.on win "close" (fn [e]
(when @*quit-dirty? ;; when not updating
(.preventDefault e)
(let [web-contents (. win -webContents)]
(.send web-contents "persist-zoom-level" (.getZoomLevel web-contents))
(.send web-contents "persistent-dbs"))
(async/go
(let [_ (async/<! state/persistent-dbs-chan)]
(if (or @win/*quitting? (not mac?))
;; MacOS: only cmd+q quitting will trigger actual closing
;; otherwise, it's just hiding - don't do any actual closing in that case
;; except saving transit
(when-let [win @*win]
(when-let [dir (state/get-window-graph-path win)]
(handler/close-watcher-when-orphaned! win dir))
(state/close-window! win)
(win/destroy-window! win)
;; FIXME: what happens when closing main window on Windows?
(reset! *win nil))
;; Just hiding - don't do any actual closing operation
(do (.preventDefault ^js/Event e)
(if (and mac? (.isFullScreen win))
(do (.once win "leave-full-screen" #(.hide win))
(.setFullScreen win false))
(.hide win)))))))))
(.on app "before-quit" (fn [_e]
(reset! win/*quitting? true)))
(.on app "activate" #(when @*win (.show win)))))))
(defn main []
(if-not (.requestSingleInstanceLock app)
(do
(db/close!)
(search/close!)
(.quit app))
(let [privileges {:standard true
@@ -251,75 +320,12 @@
(logger/debug "window-all-closed" "Quitting...")
(try
(fs-watcher/close-watcher!)
(db/close!)
(search/close!)
(catch :default e
(logger/error "window-all-closed" e)))
(.quit app)))
(.on app "ready"
(fn []
(let [t0 (setup-interceptor! app)
^js win (win/create-main-window!)
_ (reset! *win win)]
(logger/info (str "Logseq App(" (.getVersion app) ") Starting... "))
(utils/<restore-proxy-settings)
(js-utils/disableXFrameOptions win)
(search/ensure-search-dir!)
(db/ensure-graphs-dir!)
(search/open-dbs!)
(git/auto-commit-current-graph!)
(vreset! *setup-fn
(fn []
(let [t1 (setup-updater! win)
t2 (setup-app-manager! win)
t3 (handler/set-ipc-handler! win)
t4 (server/setup! win)
tt (exceptions/setup-exception-listeners!)]
(vreset! *teardown-fn
#(doseq [f [t0 t1 t2 t3 t4 tt]]
(and f (f)))))))
;; setup effects
(@*setup-fn)
;; main window events
;; TODO merge with window/on-close-actions!
;; TODO elimilate the difference between main and non-main windows
(.on win "close" (fn [e]
(when @*quit-dirty? ;; when not updating
(.preventDefault e)
(let [web-contents (. win -webContents)]
(.send web-contents "persist-zoom-level" (.getZoomLevel web-contents))
(.send web-contents "persistent-dbs"))
(async/go
(let [_ (async/<! state/persistent-dbs-chan)]
(if (or @win/*quitting? (not mac?))
;; MacOS: only cmd+q quitting will trigger actual closing
;; otherwise, it's just hiding - don't do any actual closing in that case
;; except saving transit
(when-let [win @*win]
(when-let [dir (state/get-window-graph-path win)]
(handler/close-watcher-when-orphaned! win dir))
(state/close-window! win)
(win/destroy-window! win)
;; FIXME: what happens when closing main window on Windows?
(reset! *win nil))
;; Just hiding - don't do any actual closing operation
(do (.preventDefault ^js/Event e)
(if (and mac? (.isFullScreen win))
(do (.once win "leave-full-screen" #(.hide win))
(.setFullScreen win false))
(.hide win)))))))))
(.on app "before-quit" (fn [_e]
(reset! win/*quitting? true)))
(.on app "activate" #(when @*win (.show win)))))))))
(on-app-ready! app))))
(defn start []
(logger/debug "Main - start")

View File

@@ -31,8 +31,6 @@
[repo]
(get @databases (sanitize-db-name repo)))
(declare delete-db!)
(defn prepare
[^object db sql db-name]
(when db

View File

@@ -387,8 +387,7 @@
(defmethod handle :db-transact-data [_window [_ repo data-str]]
(let [data (reader/read-string data-str)
{:keys [blocks deleted-block-uuids tx-data]} data]
;; TODO: store files
{:keys [blocks deleted-block-uuids]} data]
(when (seq deleted-block-uuids)
(db/delete-blocks! repo deleted-block-uuids))
(when (seq blocks)
@@ -407,11 +406,11 @@
(db/upsert-blocks! repo (bean/->js blocks'))))))
(defmethod handle :get-initial-data [window [_ repo _opts]]
(defmethod handle :get-initial-data [_window [_ repo _opts]]
(db/open-db! repo)
(db/get-initial-data repo))
(defmethod handle :get-other-data [window [_ repo journal-block-uuids _opts]]
(defmethod handle :get-other-data [_window [_ repo journal-block-uuids _opts]]
(db/get-other-data repo journal-block-uuids))
;; DB related IPCs End

View File

@@ -7,9 +7,8 @@
[cljs.core.match :refer [match]]
[cljs.reader :as reader]
[clojure.string :as string]
[clojure.walk :as walk]
[datascript.core :as d]
[datascript.impl.entity :as de]
[datascript.impl.entity :as e]
[dommy.core :as dom]
[frontend.commands :as commands]
[frontend.components.block.macros :as block-macros]
@@ -80,7 +79,6 @@
[reitit.frontend.easy :as rfe]
[rum.core :as rum]
[shadow.loader :as loader]
[datascript.impl.entity :as e]
[logseq.common.path :as path]))
@@ -2731,7 +2729,7 @@
(:ref? config)
(block-handler/attach-order-list-state block)))
(defn- build-block [repo config block* {:keys [navigating-block navigated?]}]
(defn- build-block [config block* {:keys [navigating-block navigated?]}]
(let [block (if (or (and (:custom-query? config)
(empty? (:block/_parent block*))
(not (and (:dsl-query? config)
@@ -2750,7 +2748,7 @@
*navigating-block (get state ::navigating-block)
navigating-block (rum/react *navigating-block)
navigated? (and (not= (:block/uuid block*) navigating-block) navigating-block)
block (build-block repo config* block* {:navigating-block navigating-block :navigated? navigated?})
block (build-block config* block* {:navigating-block navigating-block :navigated? navigated?})
{:block/keys [uuid pre-block? refs level content properties]} block
{:block.temp/keys [top?]} block
config (build-config config* block {:navigated? navigated? :navigating-block navigating-block})
@@ -3353,8 +3351,7 @@
::initial-block first-block
::navigating-block (atom (:block/uuid first-block)))))}
[state blocks config]
(let [repo (state/get-current-repo)
*navigating-block (::navigating-block state)
(let [*navigating-block (::navigating-block state)
navigating-block (rum/react *navigating-block)
navigating-block-entity (db/entity [:block/uuid navigating-block])
navigated? (and

View File

@@ -2,18 +2,11 @@
"Block properties management."
(:require [frontend.ui :as ui]
[frontend.util :as util]
[clojure.string :as string]
[frontend.handler.property :as property-handler]
[frontend.db :as db]
[rum.core :as rum]
[frontend.state :as state]
[goog.dom :as gdom]
[frontend.search :as search]
[frontend.mixins :as mixins]
;; [frontend.components.search.highlight :as highlight]
[frontend.components.svg :as svg]
[frontend.modules.shortcut.core :as shortcut]
[medley.core :as medley]
[clojure.edn :as edn]))
(rum/defcs property-class-config <

View File

@@ -7,7 +7,6 @@
[frontend.handler.route :as route-handler]
[frontend.handler.editor :as editor-handler]
[frontend.handler.page :as page-handler]
[frontend.handler.block :as block-handler]
[frontend.handler.notification :as notification]
[frontend.db :as db]
[frontend.db.model :as model]
@@ -174,14 +173,13 @@
(let [block-uuid (uuid (:block/uuid data))
collapsed? (db/parents-collapsed? repo block-uuid)
page (:block/page (db/entity [:block/uuid block-uuid]))
page-name (:block/name page)
long-page? (block-handler/long-page? repo (:db/id page))]
page-name (:block/name page)]
(if page
(cond
(model/whiteboard-page? page-name)
(route-handler/redirect-to-whiteboard! page-name {:block-id block-uuid})
(or collapsed? long-page?)
collapsed?
(route-handler/redirect-to-page! block-uuid)
:else

View File

@@ -393,7 +393,7 @@
:interactive true
:disabled false}
(svg/info))]
preferred-pasting-file?
preferred-pasting-file?
config-handler/toggle-preferred-pasting-file!))
(defn auto-expand-row [t auto-expand-block-refs?]
@@ -463,14 +463,6 @@
(let [value (not enable-all-pages-public?)]
(config-handler/set-config! :publishing/all-pages-public? value)))))
;; (defn enable-block-timestamps-row [t enable-block-timestamps?]
;; (toggle "block timestamps"
;; (t :settings-page/enable-block-time)
;; enable-block-timestamps?
;; (fn []
;; (let [value (not enable-block-timestamps?)]
;; (config-handler/set-config! :feature/enable-block-timestamps? value)))))
(rum/defc keyboard-shortcuts-row [t]
(row-with-button-action
{:left-label (t :settings-page/customize-shortcuts)
@@ -668,7 +660,6 @@
(file-format-row t preferred-format)
(date-format-row t preferred-date-format)
(workflow-row t preferred-workflow)
;; (enable-block-timestamps-row t enable-block-timestamps?)
(show-brackets-row t show-brackets?)
(when (util/electron?) (switch-spell-check-row t))
@@ -691,7 +682,7 @@
(ui/admonition
:tip
[:p (t :settings-page/git-tip)])
[:span.text-sm.opacity-50.my-4
[:span.text-sm.opacity-50.my-4
(t :settings-page/git-desc-1)]
[:br][:br]
[:span.text-sm.opacity-50.my-4
@@ -755,12 +746,12 @@
count-limit (if pro-account? 10 1)
count-percent (js/Math.round (/ count-usage count-limit 0.01))
storage-usage (->> (map :used-gbs graph-usage)
(reduce + 0))
storage-usage-formatted (cond
(reduce + 0))
storage-usage-formatted (cond
(zero? storage-usage) "0.0"
(< storage-usage 0.01) "Less than 0.01"
:else (gstring/format "%.2f" storage-usage))
;; TODO: check logic on this. What are the rules around storage limits?
;; TODO: check logic on this. What are the rules around storage limits?
;; do we, and should we be able to, give individual users more storage?
;; should that be on a per graph or per user basis?
default-storage-limit (if pro-account? 10 0.05)
@@ -774,7 +765,7 @@
[:<>
(gstring/format "%s of %s synced graphs " count-usage count-limit)
[:strong.text-white (gstring/format "(%s%%)" count-percent)]
", "])
", "])
(gstring/format "%sGB of %sGB total storage " storage-usage-formatted storage-limit)
[:strong.text-white (gstring/format "(%s%%)" storage-percent-formatted)]]))
; storage-usage-formatted "GB of " storage-limit "GB total storage"
@@ -786,13 +777,13 @@
[:div.grid.gap-3 {:style {:grid-template-columns (str "repeat(" (count graph-usage) ", 1fr)")}}
(for [{:keys [name used-percent]} graph-usage
:let [color (if (<= 100 used-percent) "bg-red-500" "bg-blue-500")]]
[:div.rounded-full.w-full.h-2 {:class "bg-black/50"
[:div.rounded-full.w-full.h-2 {:class "bg-black/50"
:tooltip name}
[:div.rounded-full.h-2 {:class color
:style {:width (str used-percent "%")
:min-width "0.5rem"
:style {:width (str used-percent "%")
:min-width "0.5rem"
:max-width "100%"}}]])]))
(rum/defc ^:large-vars/cleanup-todo settings-account < rum/reactive
[]
(let [current-graph-uuid (state/sub-current-file-sync-graph-uuid)
@@ -812,13 +803,13 @@
logged-in?
[:div.grid.grid-cols-3.gap-8.pt-2
[:div "Current plan"]
[:div.col-span-2
[:div.col-span-2
[:div {:class "w-full bg-gray-500/10 rounded-lg p-4 flex flex-col gap-4"}
[:div.flex.gap-4.items-center
(if pro-account?
[:div.flex-1 "Pro"]
[:div.flex-1 "Free"])
(cond
(cond
has-subscribed?
(ui/button "Manage plan" {:class "p-1 h-8 justify-center"
:disabled true
@@ -844,26 +835,26 @@
[:<>
[:div "Billing"]
[:div.col-span-2.flex.flex-col.gap-4
(cond
(cond
;; If there is no expiration date, print the renewal date
(and renewal-date (nil? expiration-date))
[:div
[:strong.font-semibold "Next billing date: "
(and renewal-date (nil? expiration-date))
[:div
[:strong.font-semibold "Next billing date: "
(date/get-locale-string renewal-date)]]
;; If the expiration date is in the future, word it as such
(< (js/Date.) expiration-date)
(< (js/Date.) expiration-date)
[:div
[:strong.font-semibold "Pro plan expires on: "
[:strong.font-semibold "Pro plan expires on: "
(date/get-locale-string expiration-date)]]
;; Otherwise, ind
:else
[:div
[:strong.font-semibold "Pro plan expired on: "
:else
[:div
[:strong.font-semibold "Pro plan expired on: "
(date/get-locale-string expiration-date)]])
[:div (ui/button "Open invoices" {:class "w-full h-8 p-1 justify-center"
:disabled true
:background "gray"
[:div (ui/button "Open invoices" {:class "w-full h-8 p-1 justify-center"
:disabled true
:background "gray"
:icon "receipt"})]]])
[:div "Profile"]
[:div.col-span-2.grid.grid-cols-2.gap-4
@@ -875,7 +866,7 @@
[:input.rounded.border.px-2.py-1.box-border {:class "border-blue-500 bg-black/25 w-full"}]]
[:div.flex-1.flex.flex-col.gap-2.col-span-2
[:label.text-sm.font-semibold "Username"]
[:input.rounded.border.px-2.py-1.box-border {:class "border-blue-500 bg-black/25"
[:input.rounded.border.px-2.py-1.box-border {:class "border-blue-500 bg-black/25"
:value (user-handler/email)}]]]
[:div "Authentication"]
[:div.col-span-2
@@ -889,10 +880,10 @@
:background "gray"
:icon "key"
:on-click user-handler/logout})]
[:div.col-span-2 (ui/button "Delete Account" {:class "p-1 h-8 justify-center w-full"
[:div.col-span-2 (ui/button "Delete Account" {:class "p-1 h-8 justify-center w-full"
:disabled true
:background "red"})]]]]
:background "red"})]]]]
(not logged-in?)
[:div.grid.grid-cols-3.gap-8.pt-2
[:div "Authentication"]
@@ -902,25 +893,25 @@
:on-click (fn []
(state/close-settings!)
(state/pub-event! [:user/login]))})]
[:div.flex-1 (ui/button (t :login) {:icon "login"
:class "h-8 w-full text-center justify-center"
[:div.flex-1 (ui/button (t :login) {:icon "login"
:class "h-8 w-full text-center justify-center"
:background "gray"
:on-click (fn []
(state/close-settings!)
(state/pub-event! [:user/login]))})]]
[:div.col-span-3.flex.flex-col.gap-4 {:class "bg-black/20 p-4 rounded-lg"}
[:div.flex.w-full.items-center
[:div {:class "w-1/2 text-lg"}
"Discover the power of "
[:div {:class "w-1/2 text-lg"}
"Discover the power of "
[:strong {:class "text-white/80"} "Logseq Sync"]]
[:div {:class "w-1/2 bg-gradient-to-r from-white/10 to-transparent p-3 rounded-lg flex items-center gap-2 px-5 ml-5"}
[:div {:class "w-1/2 bg-gradient-to-r from-white/10 to-transparent p-3 rounded-lg flex items-center gap-2 px-5 ml-5"}
[:div.w-3.h-3.rounded-full.bg-green-500]
"Synced"]]
[:div.flex.w-full.gap-4
[:div {:class "w-1/2 bg-black/50 rounded-lg p-4 pt-10 relative flex flex-col gap-4"}
[:div.absolute.top-0.left-4.bg-gray-700.uppercase.px-2.py-1.rounded-b-lg.font-bold.text-xs "Free"]
[:div
[:strong.text-white.text-xl.font-normal "$0"]]
[:strong.text-white.text-xl.font-normal "$0"]]
[:div.text-white.font-bold {:class "h-[2.5rem] "} "Get started with basic syncing"]
[:ul.text-xs.list-none.m-0.flex.flex-col.gap-0.5
[:li "Unlimited unsynced graphs"]
@@ -930,7 +921,7 @@
[:div {:class "w-1/2 bg-black/50 rounded-lg p-4 pt-10 relative flex flex-col gap-4"}
[:div.absolute.top-0.left-4.bg-blue-700.uppercase.px-2.py-1.rounded-b-lg.font-bold.text-xs "Pro"]
[:div
[:strong.text-white.text-xl.font-normal "$10"]
[:strong.text-white.text-xl.font-normal "$10"]
[:span.text-xs.font-base {:class "ml-0.5"} "/ month"]]
[:div.text-white.font-bold {:class "h-[2.5rem]"} "Unlock advanced syncing and more"]
[:ul.text-xs.list-none.m-0.flex.flex-col.gap-0.5
@@ -1010,7 +1001,7 @@
;; {:class (when-not user-handler/alpha-user? "opacity-50 pointer-events-none cursor-not-allowed")}
;; ;; features
;; ]])
(def DEFAULT-ACTIVE-TAB-STATE (if config/ENABLE-SETTINGS-ACCOUNT-TAB [:account :account] [:general :general]))
@@ -1027,7 +1018,6 @@
rum/reactive
[state]
(let [current-repo (state/sub :git/current-repo)
;; enable-block-timestamps? (state/enable-block-timestamps?)
_installed-plugins (state/sub :plugin/installed-plugins)
plugins-of-settings (and config/lsp-enabled? (seq (plugin-handler/get-enabled-plugins-if-setting-schema)))
*active (::active state)]
@@ -1082,7 +1072,7 @@
(reset! *active [label label])
nil)
:account
:account
(settings-account)
:general

View File

@@ -1,7 +1,6 @@
(ns frontend.db
"Main entry ns for db related fns"
(:require [datascript.core :as d]
[frontend.config :as config]
[frontend.db.conn :as conn]
[frontend.db.model]
[frontend.db.query-custom]
@@ -9,8 +8,7 @@
[frontend.db.react :as react]
[frontend.db.utils]
[frontend.namespaces :refer [import-vars]]
[logseq.db.default :as default-db]
[logseq.db.schema :as db-schema]))
[logseq.db.default :as default-db]))
(import-vars
[frontend.db.conn
@@ -70,4 +68,4 @@
(defn new-block-id
[]
(d/squuid))
(d/squuid))

View File

@@ -2,8 +2,7 @@
(:require [frontend.db.utils :as db-utils]
[frontend.db :as db]
[datascript.core :as d]
[frontend.util :as util]
[frontend.state :as state]))
[frontend.util :as util]))
;; shortcut for query a block with string ref
(defn qb

View File

@@ -22,15 +22,9 @@
[logseq.graph-parser.util :as gp-util]
[cljs-time.core :as t]
[cljs-time.format :as tf]
;; add map ops to datascript Entity
[frontend.db.datascript.entity-plus :as entity-plus]))
;; lazy loading
(def initial-blocks-length 100)
(def step-loading-blocks 50)
;; TODO: extract to specific models and move data transform logic to the
;; corresponding handlers.
@@ -564,15 +558,6 @@ independent of format as format specific heading characters are stripped"
all-ids (set (map :db/id children))]
(first (set/difference all-ids all-left)))))))
(defn get-block-last-child
[db db-id]
(let [last-child (get-block-last-direct-child db db-id)]
(loop [prev last-child
last-child last-child]
(if last-child
(recur last-child (get-block-last-direct-child db last-child))
prev))))
(defn get-prev-sibling
[db id]
(when-let [e (db-utils/entity db id)]

View File

@@ -56,28 +56,11 @@
;; component -> query-key
(defonce query-components (atom {}))
(defn- get-blocks-range
[result-atom new-result]
(let [block? (and (coll? new-result)
(map? (first new-result))
(:block/uuid (first new-result)))]
(when block?
{:old [(:db/id (first @result-atom))
(:db/id (last @result-atom))]
:new [(:db/id (first new-result))
(:db/id (last new-result))]})))
(defn set-new-result!
[k new-result tx-report]
[k new-result]
(when-let [result-atom (get-in @query-state [k :result])]
(reset! result-atom new-result)))
(defn swap-new-result!
[k f]
(when-let [result-atom (get-in @query-state [k :result])]
(let [new-result' (f @result-atom)]
(reset! result-atom new-result'))))
(defn kv
[key value]
{:db/id -1
@@ -87,7 +70,7 @@
(defn remove-key!
[repo-url key]
(db-utils/transact! repo-url [[:db.fn/retractEntity [:db/ident key]]])
(set-new-result! [repo-url :kv key] nil nil))
(set-new-result! [repo-url :kv key] nil))
(defn clear-query-state!
[]
@@ -287,8 +270,9 @@
set)))
(defn- execute-query!
[graph db k tx {:keys [query query-time inputs transform-fn query-fn inputs-fn result]}
{:keys [skip-query-time-check?]}]
[graph db k tx {:keys [query _query-time inputs transform-fn query-fn inputs-fn result]}
{:keys [_skip-query-time-check?]}]
;; FIXME:
(when true
;; (or skip-query-time-check?
;; (<= (or query-time 0) 80))
@@ -314,7 +298,7 @@
(d/q query db))
transform-fn)]
(when-not (= new-result result)
(set-new-result! k new-result tx)))))
(set-new-result! k new-result)))))
(defn path-refs-need-recalculated?
[tx-meta]
@@ -387,7 +371,8 @@
(recur))
chan))
(defn db-graph?
"Whether the current graph is db-only"
[graph]
(= "db" (sub-key-value :db/type)))
(comment
(defn db-graph?
"Whether the current graph is db-only"
[]
(= "db" (sub-key-value :db/type))))

View File

@@ -44,7 +44,6 @@
[lambdaisland.glogi :as log]
[promesa.core :as p]
[frontend.mobile.core :as mobile]
[frontend.db.react :as db-react]
[frontend.db.listener :as db-listener]
[cljs-bean.core :as bean]))
@@ -68,7 +67,7 @@
#_:clj-kondo/ignore
(let [repo (state/get-current-repo)]
(when (or
(db-react/db-graph? repo)
(config/db-based-graph? repo)
(and (not (state/nfs-refreshing?))
(not (contains? (:file/unlinked-dirs @state/state)
(config/get-repo-dir repo)))))

View File

@@ -5,7 +5,6 @@
[clojure.walk :as walk]
[frontend.db :as db]
[frontend.db.model :as db-model]
[frontend.db.react :as react]
[frontend.mobile.haptics :as haptics]
[frontend.modules.outliner.core :as outliner-core]
[frontend.modules.outliner.transaction :as outliner-tx]
@@ -16,10 +15,6 @@
;; Fns
(defn long-page?
[repo page-id]
(>= (db/get-page-blocks-count repo page-id) db-model/initial-blocks-length))
;; TODO: reduced version
(defn- walk-block
[block check? transform]

View File

@@ -11,8 +11,7 @@
(defn move-blocks
[^js event blocks target-block move-to]
(let [repo (state/get-current-repo)
blocks' (map #(db/pull (:db/id %)) blocks)
(let [blocks' (map #(db/pull (:db/id %)) blocks)
first-block (first blocks')
top? (= move-to :top)
nested? (= move-to :nested)

View File

@@ -870,7 +870,7 @@
{:label "graph-setup"})
(page-handler/ls-dir-files! st/refresh! opts'))))
(defmethod handle :graph/new-db-graph [[_ opts]]
(defmethod handle :graph/new-db-graph [[_ _opts]]
(state/set-modal!
repo/new-db-graph
{:id :new-db-graph

View File

@@ -20,7 +20,6 @@
[frontend.handler.editor :as editor]
[frontend.handler.notification :as notification]
[frontend.util :as util]
[frontend.handler.editor :as editor-handler]
[clojure.core.async :as async]
[medley.core :as medley]))
@@ -93,7 +92,7 @@
page-name (:title headers)
parsed-blocks (->>
(block/extract-blocks parsed-blocks "" :markdown {:page-name page-name})
(mapv editor-handler/wrap-parse-block))]
(mapv editor/wrap-parse-block))]
(when (not (db/page-exists? page-name))
(page-handler/create! page-name {:redirect? false}))
(let [page-block (db/entity [:block/name (util/page-name-sanity-lc page-name)])

View File

@@ -155,18 +155,6 @@
[:block/uuid (uuid %)]
(block/page-name->map % true)) refs')))
(defn delete-property!
[entity property-id]
(when (and entity (uuid? property-id))
(let [properties' (dissoc (:block/properties entity) property-id)
refs (extract-refs entity properties')]
(outliner-tx/transact!
{:outliner-op :save-block}
(outliner-core/save-block!
{:block/uuid (:block/uuid entity)
:block/properties properties'
:block/refs refs})))))
(defn validate
"Check whether the `value` validate against the `schema`."
[schema value]
@@ -206,6 +194,18 @@
value)]
[true page-name]))))
(defn delete-property!
[entity property-id]
(when (and entity (uuid? property-id))
(let [properties' (dissoc (:block/properties entity) property-id)
refs (extract-refs entity properties')]
(outliner-tx/transact!
{:outliner-op :save-block}
(outliner-core/save-block!
{:block/uuid (:block/uuid entity)
:block/properties properties'
:block/refs refs})))))
(defn delete-property-value!
"Delete value if a property has multiple values"
[entity property-id property-value]

View File

@@ -2,7 +2,6 @@
(:require [datascript.core :as d]
[frontend.db.conn :as conn]
[frontend.db :as db]
[frontend.db.react :as react]
[frontend.modules.outliner.pipeline :as pipelines]
[frontend.modules.editor.undo-redo :as undo-redo]
[frontend.state :as state]

View File

@@ -17,7 +17,7 @@
(defn updated-page-hook
[tx-report page]
(when (and
(not (react/db-graph? (state/get-current-repo)))
(not (config/db-based-graph? (state/get-current-repo)))
(not (get-in tx-report [:tx-meta :created-from-journal-template?])))
(file/sync-to-file page (:outliner-op (:tx-meta tx-report)))))
@@ -157,10 +157,10 @@
(map (fn [b]
(let [uuid (or (:block/uuid b) (random-uuid))]
(assoc b :block/uuid uuid)))))]
(p/let [ipc-result (ipc/ipc :db-transact-data repo
(pr-str
{:blocks upsert-blocks
:deleted-block-uuids deleted-block-uuids}))]
(p/let [_ipc-result (ipc/ipc :db-transact-data repo
(pr-str
{:blocks upsert-blocks
:deleted-block-uuids deleted-block-uuids}))]
;; TODO: disable edit when transact failed to avoid future data-loss
;; (prn "DB transact result: " ipc-result)
)))

View File

@@ -15,7 +15,6 @@
[:journal/page-title-format :string]
[:ui/enable-tooltip? :boolean]
[:ui/show-brackets? :boolean]
[:feature/enable-block-timestamps? :boolean]
[:feature/enable-search-remove-accents? :boolean]
[:feature/enable-journals? :boolean]
[:feature/enable-flashcards? :boolean]

View File

@@ -16,7 +16,6 @@
[goog.object :as gobj]
[promesa.core :as p]
[clojure.set :as set]
[frontend.modules.datascript-report.core :as db-report]
[datascript.core :as d]))
(defn get-engine

View File

@@ -618,10 +618,6 @@ Similar to re-frame subscriptions"
[repo]
(not (false? (:git-auto-push (sub-config repo)))))
(defn enable-block-timestamps?
[]
(true? (:feature/enable-block-timestamps? (sub-config))))
(defn graph-settings
[]
(:graph/settings (sub-config)))

View File

@@ -294,7 +294,6 @@
:settings-page/edit-global-config-edn "Globale config.edn bearbeiten"
:settings-page/edit-setting "Bearbeiten"
:settings-page/enable-all-pages-public "Alle Seiten bei Veröffentlichung öffentlich"
:settings-page/enable-block-time "Zeitstempel für Blöcke aktivieren"
:settings-page/enable-flashcards "Karteikarten"
:settings-page/enable-journals "Journale einschalten"
:settings-page/enable-shortcut-tooltip "Tooltips für Verknüpfungen aktivieren"

View File

@@ -293,7 +293,6 @@
:settings-page/customize-shortcuts "Keyboard shortcuts"
:settings-page/shortcut-settings "Customize shortcuts"
:settings-page/home-default-page "Set the default home page"
:settings-page/enable-block-time "Block timestamps"
:settings-page/clear-cache "Clear cache"
:settings-page/clear "Clear"
:settings-page/clear-cache-warning "Clearing the cache will discard open graphs. You will lose unsaved changes."

View File

@@ -134,7 +134,6 @@
:settings-page/customize-shortcuts "Atajos de teclado"
:settings-page/shortcut-settings "Personalizar atajos"
:settings-page/home-default-page "Establecer página de inicio"
:settings-page/enable-block-time "Habilitar marcas temporales de bloque"
:settings-page/clear-cache "Limpiar caché"
:settings-page/clear "Limpiar"
:settings-page/developer-mode "Modo desarrollador"

View File

@@ -266,7 +266,6 @@
:settings-page/edit-global-config-edn "Modifier le fichier global config.edn"
:settings-page/edit-setting "Modifier"
:settings-page/enable-all-pages-public "Toutes les pages publiques lors de la publication"
:settings-page/enable-block-time "Horodatage de bloc"
:settings-page/enable-flashcards "Cartes-mémoire"
:settings-page/enable-shortcut-tooltip "Activer les astuces sur les raccourcis"
:settings-page/enable-tooltip "Astuces"

View File

@@ -105,7 +105,6 @@
:settings-page/customize-shortcuts "Scorciatoie da tastiera"
:settings-page/shortcut-settings "Personalizza scorciatoie"
:settings-page/home-default-page "Imposta la home page predefinita"
:settings-page/enable-block-time "Indicatori temporali sui blocchi"
:settings-page/clear-cache "Pulisci cache"
:settings-page/clear "Pulisci"
:settings-page/developer-mode "Modalità sviluppatore"

View File

@@ -110,7 +110,6 @@
:settings-page/customize-shortcuts "キーボードショートカット"
:settings-page/shortcut-settings "ショートカットをカスタマイズ"
:settings-page/home-default-page "デフォルトのホームページを設定"
:settings-page/enable-block-time "ブロックタイムスタンプ"
:settings-page/clear-cache "キャッシュをクリア"
:settings-page/clear "クリア"
:settings-page/developer-mode "開発者モード"

View File

@@ -107,7 +107,6 @@
:settings-page/customize-shortcuts "키보드 단축키"
:settings-page/shortcut-settings "단축키 설정"
:settings-page/home-default-page "기본 홈 페이지 설정"
:settings-page/enable-block-time "블록 타임스탬프"
:settings-page/clear-cache "캐시 지우기"
:settings-page/clear "지우기"
:settings-page/developer-mode "개발자 모드"

View File

@@ -105,7 +105,6 @@
:settings-page/customize-shortcuts "Tastatursnarveier"
:settings-page/shortcut-settings "Tilpass snarveier"
:settings-page/home-default-page "Angi standard hjemmeside"
:settings-page/enable-block-time "Aktiver tidsstempel for blokker"
:settings-page/clear-cache "Slett hurtigbuffer"
:settings-page/clear "Slett"
:settings-page/developer-mode "Utviklermodus"

View File

@@ -200,7 +200,6 @@
:settings-page/edit-custom-css "Bewerk custom.css"
:settings-page/edit-export-css "Bewerk export.css"
:settings-page/enable-all-pages-public "Alle pagina's openbaar bij publiceren"
:settings-page/enable-block-time "Tijdstempel voor blokken inschakelen"
:settings-page/enable-journals "Journaals"
:settings-page/enable-shortcut-tooltip "Snelkoppeling tooltip inschakelen"

View File

@@ -110,7 +110,6 @@
:settings-page/customize-shortcuts "Skróty klawiszowe"
:settings-page/shortcut-settings "Zmień skróty"
:settings-page/home-default-page "Ustaw domyślną stronę startową"
:settings-page/enable-block-time "Włącz czas dla bloków"
:settings-page/clear-cache "Wyczyść cache"
:settings-page/clear "Wyczyść"
:settings-page/developer-mode "Tryb programisty"

View File

@@ -86,7 +86,6 @@
:settings-page/customize-shortcuts "Atalhos de teclado"
:settings-page/shortcut-settings "Personalizar atalhos"
:settings-page/home-default-page "Definir a página inicial padrão"
:settings-page/enable-block-time "Ativar carimbos temporais nos blocos"
:settings-page/clear-cache "Limpar cache"
:settings-page/clear "Limpar"
:settings-page/developer-mode "Modo de desenvolvimento"

View File

@@ -177,7 +177,6 @@
:settings-page/customize-shortcuts "Atalhos de teclado"
:settings-page/shortcut-settings "Personalizar atalhos"
:settings-page/home-default-page "Definir a página inicial predefinida"
:settings-page/enable-block-time "Marcas de tempo em blocos"
:settings-page/clear-cache "Limpar cache"
:settings-page/clear "Limpar"
:settings-page/clear-cache-warning "Limpar a cache irá descartar todos os grafos abertos. Perderá as alterações não guardadas."

View File

@@ -218,7 +218,6 @@
:settings-page/customize-shortcuts "Сочетания клавиш"
:settings-page/shortcut-settings "Настроить горячие клавиши"
:settings-page/home-default-page "Установить домашнюю страницу по умолчанию"
:settings-page/enable-block-time "Временные метки блока"
:settings-page/clear-cache "Очистить кэш"
:settings-page/clear "Очистить"
:settings-page/clear-cache-warning "Очистка кэша приведет к удалению открытых графов. Вы потеряете несохраненные изменения."

View File

@@ -170,7 +170,6 @@
:settings-page/customize-shortcuts "Klávesové skratky"
:settings-page/shortcut-settings "Prispôsobiť skratky"
:settings-page/home-default-page "Nastaviť predvolenú domovskú stránku"
:settings-page/enable-block-time "Povoliť časové pečiatky bloku"
:settings-page/clear-cache "Vymazať vyrovnávaciu pamäť"
:settings-page/clear "Vymazať"
:settings-page/clear-cache-warning "Vymazaním vyrovnávacej pamäte sa vymažú otvorené grafy. Prídete o neuložené zmeny."

View File

@@ -292,7 +292,6 @@
:settings-page/customize-shortcuts "Klavye kısayolları"
:settings-page/shortcut-settings "Kısayolları özelleştir"
:settings-page/home-default-page "Varsayılan ana sayfayı ayarla"
:settings-page/enable-block-time "Blok zaman damgaları"
:settings-page/clear-cache "Önbelleği temizle"
:settings-page/clear "Temizle"
:settings-page/clear-cache-warning "Önbelleği temizlemek açık grafları atacaktır. Kaydedilmemiş değişiklikleri kaybedersiniz."
@@ -329,7 +328,7 @@
:settings-page/update-error-1 "⚠️ Ne yazık ki bir sorun oluştu!"
:settings-page/update-error-2 " Lütfen bu bağlantıyı denetleyin: "
:yes "Evet"
:submit "Onayla"
:cancel "İptal"
:close "Kapat"
@@ -584,7 +583,7 @@
:paginates/pages "Toplam {1} sayfa"
:paginates/prev "Önceki"
:paginates/next "Sonraki"
:tips/all-done "Tamamlandı!"
:command-palette/prompt "Bir komut yazın"
@@ -615,13 +614,13 @@
:window/restore "Pencere durumuna dön"
:window/close "Kapat"
:window/exit-fullscreen "Tam ekrandan çık"
:header/toggle-left-sidebar "Sol kenar çubuğunu aç/kapat"
:header/search "Ara"
:header/more "Diğer"
:header/go-back "Geri git"
:header/go-forward "İleri git"
:command.date-picker/complete "Tarih seçici: Seçilen günü seç"
:command.date-picker/prev-day "Tarih seçici: Önceki günü seç"
:command.date-picker/next-day "Tarih seçici: Sonraki günü seç"

View File

@@ -201,7 +201,6 @@
:settings-page/customize-shortcuts "Гарячі клавіші"
:settings-page/shortcut-settings "Налаштуваня ярликів"
:settings-page/home-default-page "Встановити домашню сторінку за умовчанням"
:settings-page/enable-block-time "Блокувати позначки часу"
:settings-page/clear-cache "Очистити кеш"
:settings-page/clear "Очистити"
:settings-page/clear-cache-warning "Очищення кешу призведе до видалення відкритих графіків. Ви втратите незбережені зміни."

View File

@@ -167,7 +167,6 @@
:settings-page/customize-shortcuts "自定义快捷键"
:settings-page/shortcut-settings "快捷键设置"
:settings-page/home-default-page "设置首页默认页面"
:settings-page/enable-block-time "记录 block 创建/修改时间"
:settings-page/clear-cache "清除缓存"
:settings-page/clear "清除"
:settings-page/clear-cache-warning "清除缓存将关闭当前打开的图谱。你将丢失未保存的更改。"

View File

@@ -175,7 +175,6 @@
:settings-page/customize-shortcuts "個人化快捷鍵"
:settings-page/shortcut-settings "設定快捷鍵"
:settings-page/home-default-page "設定預設首頁"
:settings-page/enable-block-time "啟用區塊時間截記"
:settings-page/clear-cache "清除快取資料"
:settings-page/clear "清除"
:settings-page/clear-cache-warning "清除快取將捨棄目前的圖表。未儲存的資料將無法復原。"

View File

@@ -52,10 +52,6 @@
;; Default value: true
:ui/auto-expand-block-refs? true
;; Enable Block timestamps.
;; Default value: false
:feature/enable-block-timestamps? false
;; Disable accent marks when searching.
;; After changing this setting, rebuild the search index by pressing (^C ^S).
;; Default value: true