enhance: limit access to db graphs only

This commit is contained in:
Tienson Qin
2025-12-26 16:38:59 +08:00
parent 8b312a4031
commit 8fe3cddba7
3 changed files with 18 additions and 13 deletions

View File

@@ -26,7 +26,6 @@
(->> (common-graph/read-directories dir)
(remove (fn [s] (= s common-config/unlinked-graphs-dir)))
(map graph-name->path)
(map (fn [s]
(if (string/starts-with? s common-config/file-version-prefix)
s
(str common-config/db-version-prefix s)))))))
(keep (fn [s]
(when-not (string/starts-with? s common-config/file-version-prefix)
(str common-config/db-version-prefix s)))))))

View File

@@ -190,11 +190,13 @@
repos (util/distinct-by :url repos)
remotes (state/sub :rtc/graphs)
remotes-loading? (state/sub :rtc/loading-graphs?)
repos (if (and login? (seq remotes))
(repo-handler/combine-local-&-remote-graphs repos remotes) repos)
repos (->> (if (and login? (seq remotes))
(repo-handler/combine-local-&-remote-graphs repos remotes)
repos)
(util/distinct-by :url))
repos (cond->>
(remove #(= (:url %) config/demo-repo) repos)
(util/mobile?)
true
(filter (fn [item]
;; use `config/db-based-graph?` to avoid loading old file graphs
(config/db-based-graph? (:url item)))))
@@ -318,9 +320,12 @@
downloading-graph-id (state/sub :rtc/downloading-graph-uuid)
remotes-loading? (state/sub :rtc/loading-graphs?)
repos (sort-repos-with-metadata-local repos)
repos (distinct
repos (->>
(if (and (seq rtc-graphs) login?)
(repo-handler/combine-local-&-remote-graphs repos rtc-graphs) repos))
(repo-handler/combine-local-&-remote-graphs repos rtc-graphs)
repos)
(util/distinct-by :url))
items-fn #(repos-dropdown-links repos current-repo downloading-graph-id opts)
header-fn #(when (> (count repos) 1) ; show switch to if there are multiple repos
[:div.font-medium.md:text-sm.md:opacity-50.p-2.flex.flex-row.justify-between.items-center

View File

@@ -17,10 +17,11 @@
(str config/db-version-prefix name)))
repos)
electron-disk-graphs (when (util/electron?) (ipc/ipc "getGraphs"))]
(distinct (concat
repos'
(map (fn [repo-name] {:name repo-name})
(some-> electron-disk-graphs bean/->clj))))))
(distinct
(concat
repos'
(map (fn [repo-name] {:name repo-name})
(some-> electron-disk-graphs bean/->clj))))))
(defn delete-graph!
[graph]