Procházet zdrojové kódy

enhance: limit access to db graphs only

Tienson Qin před 6 dny
rodič
revize
8fe3cddba7

+ 3 - 4
deps/cli/src/logseq/cli/common/graph.cljs

@@ -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)))))))

+ 10 - 5
src/main/frontend/components/repo.cljs

@@ -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

+ 5 - 4
src/main/frontend/db/persist.cljs

@@ -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]