diff --git a/web/src/main/frontend/components/content.cljs b/web/src/main/frontend/components/content.cljs index d7b46b82c..3769d280d 100644 --- a/web/src/main/frontend/components/content.cljs +++ b/web/src/main/frontend/components/content.cljs @@ -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")) diff --git a/web/src/main/frontend/components/file.cljs b/web/src/main/frontend/components/file.cljs index f56ef6a9c..e0466c8c0 100644 --- a/web/src/main/frontend/components/file.cljs +++ b/web/src/main/frontend/components/file.cljs @@ -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 diff --git a/web/src/main/frontend/components/repo.cljs b/web/src/main/frontend/components/repo.cljs index ed0350355..12f6c9762 100644 --- a/web/src/main/frontend/components/repo.cljs +++ b/web/src/main/frontend/components/repo.cljs @@ -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} diff --git a/web/src/main/frontend/db.cljs b/web/src/main/frontend/db.cljs index bb9a2953d..ad223be29 100644 --- a/web/src/main/frontend/db.cljs +++ b/web/src/main/frontend/db.cljs @@ -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]]))) diff --git a/web/src/main/frontend/handler.cljs b/web/src/main/frontend/handler.cljs index 680c881ba..8f78ca88f 100644 --- a/web/src/main/frontend/handler.cljs +++ b/web/src/main/frontend/handler.cljs @@ -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))