Re-enable custom queries

pull/645/head
Tienson Qin 2020-06-07 08:27:51 +08:00
parent a4133956c4
commit 608fd6c7a5
5 changed files with 24 additions and 34 deletions

View File

@ -47,7 +47,8 @@
(mixins/listen state js/window "mouseup"
(fn [e]
(when-let [headings (seq (util/get-selected-nodes "ls-heading-parent"))]
(let [headings (remove #(d/has-class? % "dummy") headings)]
(let [headings (remove nil? headings)
headings (remove #(d/has-class? % "dummy") headings)]
(when (seq headings)
(doseq [heading headings]
(d/add-class! heading "selected noselect"))

View File

@ -53,11 +53,9 @@
(let [[encoded-path path] (get-path state)
format (format/get-format path)
save-file-handler (fn [content]
(fn [_]
(when (handler/file-changed? encoded-path content)
(let [new-content (-> (gdom/getElement encoded-path)
(gobj/get "value"))]
(handler/alter-file (state/get-current-repo) path new-content nil)))))
(fn [value]
(when (not= (string/trim value) (string/trim content))
(handler/alter-file (state/get-current-repo) path (string/trim value) nil))))
edit-raw-handler (fn []
(let [content (db/get-file path)]
(content/content encoded-path {:content content

View File

@ -20,13 +20,10 @@
[:h1.title "Your Repos: "]
[:div.pl-1.content
;; [:a {:href "/repo/add"}
;; "Add another repo"]
(ui/button
"Add another repo"
:href "/repo/add"
;; :on-click identity
:style {:margin-bottom 24})
[:div.flex.my-4 {:key "add-button"}
(ui/button
"Add another repo"
:href "/repo/add")]
(for [{:keys [id url] :as repo} repos]
[:div.flex.justify-between.mb-1 {:key id}

View File

@ -293,20 +293,18 @@
(if (= k :page/refed-headings)
[:page/ref-pages page-id]))
handler-keys)
;; custom-queries (some->>
;; (filter (fn [v]
;; (and (= (first v) (state/get-current-repo))
;; (= (second v) :custom)))
;; (keys @query-state))
;; (map (fn [v]
;; (vec (drop 1 v)))))
]
custom-queries (some->>
(filter (fn [v]
(and (= (first v) (state/get-current-repo))
(= (second v) :custom)))
(keys @query-state))
(map (fn [v]
(vec (drop 1 v)))))]
(->>
(util/concat-without-nil
handler-keys
refed-pages
;; custom-queries
)
custom-queries)
distinct)))
[[key]])))

View File

@ -470,11 +470,11 @@
(notify-fn)
(js/setInterval notify-fn (* 1000 60)))))
(defn file-changed?
[input-id content]
(when-let [input (gdom/getElement input-id)]
(not= (string/trim content)
(string/trim (gobj/get input "value")))))
(defn restore-config!
[repo-url]
(p/let [content (load-file repo-url config/config-file)]
(when content
(db/reset-config! repo-url content))))
(defn alter-file
[repo path content {:keys [reset? re-render-root?]
@ -487,6 +487,8 @@
(fs/write-file (util/get-repo-dir repo) path content)
(fn [_]
(git-add repo path)
(when (= path config/config-file)
(restore-config! repo))
(when re-render-root? (re-render-root!))
(history/add-history!
[:git/repo repo]
@ -1186,12 +1188,6 @@
(clone-and-pull-repos me))))
(fn [_e])))))
(defn restore-config!
[repo-url]
(p/let [content (load-file repo-url config/config-file)]
(when content
(db/reset-config! repo-url content))))
(defn watch-for-date!
[]
(state/set-today! (date/today))