Address review feedback

pull/4023/head
Gabriel Horner 2022-01-28 10:48:44 -05:00
parent 664b32e03a
commit 54420c9a5d
12 changed files with 2 additions and 99 deletions

View File

@ -49,17 +49,11 @@ frontend.components.svg/settings
frontend.components.svg/arrow-expand
;; Used by shadow-cljs
frontend.core/stop
;; Referenced in comment
frontend.db.model/with-children-refs
;; Referenced in comment
frontend.db.model/get-latest-changed-pages
;; For repl
frontend.db.utils/q
;; For debugging
frontend.debug/defn
frontend.debug/print
;; Left as an example
frontend.diff/diffs
;; Lazily loaded
frontend.extensions.code/editor
;; Lazily loaded

View File

@ -83,7 +83,6 @@
"codemirror": "5.58.1",
"d3-force": "3.0.0",
"diff": "5.0.0",
"diff-match-patch": "1.0.5",
"electron": "15.1.2",
"fs": "0.0.1-security",
"fs-extra": "9.1.0",

View File

@ -389,9 +389,3 @@
(defn get-block-hidden-properties
[]
(get-in @state/state [:config (state/get-current-repo) :block-hidden-properties]))
(defn get-static-path
[]
(if (and (util/electron?) dev?)
"static/"
""))

View File

@ -89,8 +89,7 @@
(when conn
(let [db (d/db conn)
db-str (if db (db->string db) "")]
(p/let [_ (db-persist/save-graph! key db-str)]
(state/set-last-persist-transact-id! repo false (get-max-tx-id db)))))))
(p/let [_ (db-persist/save-graph! key db-str)])))))
(defonce persistent-jobs (atom {}))

View File

@ -15,7 +15,6 @@
[frontend.format :as format]
[frontend.state :as state]
[frontend.util :as util :refer [react]]
[medley.core :as medley]
[frontend.db.rules :refer [rules]]
[frontend.db.default :as default-db]))
@ -930,27 +929,6 @@
(let [result (d/datoms db :avet :block/parent (:db/id block))]
(boolean (seq result)))))))
;; TODO: improve perf
(defn with-children-refs
[repo blocks]
(when-let [conn (conn/get-conn repo)]
(when (seq blocks)
(let [block-ids (set (map :db/id blocks))
refs (d/q
'[:find ?p ?ref
:in $ % ?block-ids
:where
(parent ?p ?b)
[(contains? ?block-ids ?p)]
[?b :block/refs ?ref]]
conn
rules
block-ids)
refs (->> (group-by first refs)
(medley/map-vals #(set (map (fn [[_ id]] {:db/id id}) %))))]
(map (fn [block] (assoc block :block/children-refs
(get refs (:db/id block)))) blocks)))))
(defn get-page-referenced-blocks-no-cache
[page-id]
(when-let [repo (state/get-current-repo)]
@ -1000,7 +978,6 @@
(sort-by-left-recursive)
(remove (fn [block]
(= page-id (:db/id (:block/page block)))))
;; (with-children-refs repo)
db-utils/group-by-page
(map (fn [[k blocks]]
(let [k (if (contains? aliases (:db/id k))
@ -1483,18 +1460,6 @@
{:block/file [:db/id :file/path]}]
ids))))))
(defn get-latest-changed-pages
[repo]
(->>
(d/q
'[:find [(pull ?page [:block/name :block/file :block/updated-at]) ...]
:where
[?page :block/name]]
(conn/get-conn repo))
(filter :block/file)
(sort-by :block/updated-at >)
(take 200)))
(defn get-orphaned-pages
[{:keys [repo pages empty-ref-f]
:or {repo (state/get-current-repo)

View File

@ -1,25 +1,17 @@
(ns frontend.diff
(:require [clojure.string :as string]
["diff" :as jsdiff]
["diff-match-patch" :as diff-match-patch]
[goog.object :as gobj]
[lambdaisland.glogi :as log]
[cljs-bean.core :as bean]
[frontend.util :as util]
[frontend.text :as text]))
;; TODO: replace with diff-match-patch
(defn diff
[s1 s2]
(-> ((gobj/get jsdiff "diffLines") s1 s2)
bean/->clj))
(defonce dmp (diff-match-patch.))
(defn diffs
[s1 s2]
(.diff_main dmp s1 s2 true))
(def inline-special-chars
#{\* \_ \/ \` \+ \^ \~ \$})

View File

@ -2,7 +2,6 @@
(:require [cljs-bean.core :as bean]
[electron.ipc :as ipc]
[electron.listener :as el]
[frontend.components.editor :as editor]
[frontend.components.page :as page]
[frontend.config :as config]
[frontend.db :as db]
@ -206,7 +205,6 @@
(defn- register-components-fns!
[]
(state/set-page-blocks-cp! page/page-blocks-cp)
(state/set-editor-cp! editor/box)
(command-palette/register-global-shortcut-commands))
(defn start!

View File

@ -375,14 +375,3 @@
new-result (rewrite/assoc-in result ks v)
new-content (str new-result)]
(set-file-content! repo path new-content)))))
;; TODO:
;; (defn compare-latest-pages
;; []
;; (when-let [repo (state/get-current-repo)]
;; (doseq [{:block/keys [file name]} (db/get-latest-changed-pages repo)]
;; (when-let [path (:file/path (db/pull (:db/id file)))]
;; (p/let [content (load-file repo path)]
;; (when (not= (string/trim content) (string/trim (or (db/get-file repo path) "")))
;; ;; notify
;; ))))))

View File

@ -12,7 +12,6 @@
[reitit.frontend.easy :as rfe]
[cljs.reader :as reader]
[frontend.components.page :as component-page]
[frontend.components.editor :as component-editor]
[frontend.modules.shortcut.core :as shortcut]
[frontend.handler.events :as events]))
@ -62,8 +61,7 @@
(defn- register-components-fns!
[]
(state/set-page-blocks-cp! component-page/page-blocks-cp)
(state/set-editor-cp! component-editor/box))
(state/set-page-blocks-cp! component-page/page-blocks-cp))
(defn ^:export init []
;; init is called ONCE when the page loads

View File

@ -1322,10 +1322,6 @@
;; not in editing mode
(not (get-edit-input-id)))))
(defn set-last-persist-transact-id!
[_repo files? id]
(swap! state assoc-in [:db/last-persist-transact-ids :repo files?] id))
(defn set-nfs-refreshing!
[value]
(set-state! :nfs/refreshing? value))
@ -1497,10 +1493,6 @@
[]
(get-in @state [:view/components :page-blocks]))
(defn set-editor-cp!
[value]
(set-state! [:view/components :editor] value))
(defn exit-editing-and-set-selected-blocks!
([blocks]
(exit-editing-and-set-selected-blocks! blocks :down))

View File

@ -1025,12 +1025,6 @@
[s]
(removeAccents (.normalize (string/lower-case s) "NFKC"))))
#?(:cljs
(defn safe-search-normalize
[s]
(if (string? s)
(removeAccents (.normalize (string/lower-case s) "NFKC")) s)))
(defn page-name-sanity
"Sanitize the page-name for file name (strict), for file writting"
([page-name]
@ -1365,12 +1359,6 @@
[v]
(string/trim (subs v 1 (dec (count v)))))
(defn unquote-string-if-wrapped
[v]
(if (wrapped-by-quotes? v)
(unquote-string v)
v))
#?(:cljs
(defn right-click?
[e]

View File

@ -2763,11 +2763,6 @@ didyoumean@^1.2.1:
resolved "https://registry.yarnpkg.com/didyoumean/-/didyoumean-1.2.2.tgz#989346ffe9e839b4555ecf5666edea0d3e8ad037"
integrity sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==
diff-match-patch@1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/diff-match-patch/-/diff-match-patch-1.0.5.tgz#abb584d5f10cd1196dfc55aa03701592ae3f7b37"
integrity sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==
diff-sequences@^27.4.0:
version "27.4.0"
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.4.0.tgz#d783920ad8d06ec718a060d00196dfef25b132a5"