fix: open db graph urls

Also introduced var for logseq_db_ in deps
This commit is contained in:
Gabriel Horner
2023-11-27 10:55:22 -05:00
parent c468d05845
commit 5e547a1663
6 changed files with 27 additions and 20 deletions

View File

@@ -245,7 +245,7 @@
(->> (common-graph/read-directories dir)
(remove (fn [s] (= s db/unlinked-graphs-dir)))
(map graph-name->path)
(map (fn [s] (str "logseq_db_" s))))))
(map (fn [s] (str sqlite-util/db-version-prefix s))))))
(defn- get-graphs
[]
@@ -255,13 +255,15 @@
;; TODO support alias mechanism
(defn get-graph-name
"Given a graph's name of string, returns the graph's fullname.
E.g., given `cat`, returns `logseq_local_<path_to_directory>/cat`
Returns `nil` if no such graph exists."
"Given a graph's name of string, returns the graph's fullname. For example, given
`cat`, returns `logseq_local_<path_to_directory>/cat` for a file graph and
`logseq_db_cat` for a db graph. Returns `nil` if no such graph exists."
[graph-identifier]
(->> (get-graphs)
(some #(when (string/ends-with? (utils/normalize-lc %)
(str "/" (utils/normalize-lc graph-identifier)))
(some #(when (or
(= (utils/normalize-lc %) (utils/normalize-lc (str sqlite-util/db-version-prefix graph-identifier)))
(string/ends-with? (utils/normalize-lc %)
(str "/" (utils/normalize-lc graph-identifier))))
%))))
(defmethod handle :getGraphs [_window [_]]

View File

@@ -229,9 +229,7 @@
(let [remote? (:remote? (first (filter #(= current-repo (:url %)) repos)))
repo-name (db/get-repo-name current-repo)
short-repo-name (if repo-name
(if (config/db-based-graph? repo-name)
(string/replace-first repo-name config/db-version-prefix "")
(db/get-short-repo-name repo-name))
(db/get-short-repo-name repo-name)
"Select a Graph")]
[:a.item.group.flex.items-center.p-2.text-sm.font-medium.rounded-md

View File

@@ -36,15 +36,18 @@
(defn get-short-repo-name
"repo-name: from get-repo-name. Dir/Name => Name"
[repo-name]
(cond
(util/electron?)
(text/get-file-basename repo-name)
(let [repo-name' (cond
(util/electron?)
(text/get-file-basename repo-name)
(mobile-util/native-platform?)
(gp-util/safe-decode-uri-component (text/get-file-basename repo-name))
(mobile-util/native-platform?)
(gp-util/safe-decode-uri-component (text/get-file-basename repo-name))
:else
repo-name))
:else
repo-name)]
(if (config/db-based-graph? repo-name')
(string/replace-first repo-name' config/db-version-prefix "")
repo-name')))
(defn datascript-db
[repo]