Skip to content

Commit

Permalink
Fix edit global config.edn
Browse files Browse the repository at this point in the history
This also effects editing any file that's not in the current repo
  • Loading branch information
logseq-cldwalker committed Feb 21, 2023
1 parent 021a017 commit 047f8a8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/frontend/components/file.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
[goog.object :as gobj]
[reitit.frontend.easy :as rfe]
[rum.core :as rum]
[promesa.core :as p]))
[promesa.core :as p]
["path" :as path]))

(defn- get-path
[state]
Expand Down Expand Up @@ -73,11 +74,12 @@
(rum/defcs file-inner < rum/reactive
{:will-mount (fn [state]
(let [*content (atom nil)
[path format] (:rum/args state)]
[path format] (:rum/args state)
repo-dir (config/get-repo-dir (state/get-current-repo))
dir (if (string/includes? path repo-dir) repo-dir (path/dirname path))]
(when (and format (contains? (gp-config/text-formats) format))
(p/let [content (fs/read-file
(config/get-repo-dir (state/get-current-repo)) path)]
(reset! *content content)))
(p/let [content (fs/read-file dir path)]
(reset! *content content)))
(assoc state ::file-content *content)))
:did-mount (fn [state]
(state/set-file-component! (:rum/react-component state))
Expand Down

0 comments on commit 047f8a8

Please sign in to comment.