Merge configs and create global config file if not present

- Cleanup repo and global config with system components
- test merging
- fix edge cases
This commit is contained in:
Gabriel Horner
2022-09-02 22:43:41 -04:00
committed by Andelf
parent cbcc19309d
commit b1d210d26b
22 changed files with 415 additions and 267 deletions

View File

@@ -32,6 +32,8 @@
[frontend.handler.page :as page-handler]
[frontend.handler.plugin :as plugin-handler]
[frontend.handler.repo :as repo-handler]
[frontend.handler.global-config :as global-config-handler]
[frontend.handler.repo-config :as repo-config-handler]
[frontend.handler.route :as route-handler]
[frontend.handler.search :as search-handler]
[frontend.handler.ui :as ui-handler]
@@ -113,12 +115,13 @@
(do
(state/set-current-repo! graph)
;; load config
(common-handler/reset-config! graph nil)
(repo-config-handler/restore-repo-config! graph)
(st/refresh!)
(when-not (= :draw (state/get-current-route))
(route-handler/redirect-to-home!))
(when-let [dir-name (config/get-repo-dir graph)]
(fs/watch-dir! dir-name))
(global-config-handler/watch-for-global-config-dir! graph)
(srs/update-cards-due-count!)
(state/pub-event! [:graph/ready graph])
(repo-handler/refresh-repos!)
@@ -451,7 +454,7 @@
(state/set-current-repo! current-repo)
(db/listen-and-persist! current-repo)
(db/persist-if-idle! current-repo)
(file-handler/restore-config! current-repo)
(repo-config-handler/restore-repo-config! current-repo)
(.watch mobile-util/fs-watcher #js {:path current-repo-dir})
(when graph-switch-f (graph-switch-f current-repo true))
(file-sync-restart!))))
@@ -503,7 +506,7 @@
(defmethod handle :backup/broken-config [[_ repo content]]
(when (and repo content)
(let [path (config/get-config-path)
(let [path (config/get-repo-config-path)
broken-path (string/replace path "/config.edn" "/broken-config.edn")]
(p/let [_ (fs/write-file! repo (config/get-repo-dir repo) broken-path content {})
_ (file-handler/alter-file repo path config/config-default-content {:skip-compare? true})]