mirror of
https://github.com/logseq/logseq.git
synced 2026-05-21 03:12:38 +00:00
feat: upload local graph to server
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
(ns frontend.components.repo
|
||||
(:require [clojure.string :as string]
|
||||
[frontend.common.async-util :as async-util]
|
||||
[frontend.components.rtc.indicator :as rtc-indicator]
|
||||
[frontend.config :as config]
|
||||
[frontend.context.i18n :refer [t]]
|
||||
[frontend.db :as db]
|
||||
@@ -125,6 +126,27 @@
|
||||
(repo-handler/remove-repo! repo)
|
||||
(state/pub-event! [:graph/unlinked repo (state/get-current-repo)]))))))}
|
||||
"Delete local graph"))
|
||||
(when (and db-based? root (not remote?))
|
||||
(shui/dropdown-menu-item
|
||||
{:key "logseq-sync"
|
||||
:class "use-logseq-sync-menu-item"
|
||||
:on-click (fn []
|
||||
(let [repo (state/get-current-repo)
|
||||
token (state/get-auth-id-token)
|
||||
remote-graph-name (config/db-graph-name (state/get-current-repo))]
|
||||
(when (and token remote-graph-name)
|
||||
(state/<invoke-db-worker :thread-api/rtc-async-upload-graph
|
||||
repo token remote-graph-name)
|
||||
(when (util/mobile?)
|
||||
(shui/popup-show! nil
|
||||
(fn []
|
||||
(rtc-indicator/uploading-logs))
|
||||
{:id :rtc-graph-upload-log})
|
||||
(rtc-indicator/on-upload-finished-task
|
||||
(fn []
|
||||
(shui/popup-hide! :rtc-graph-upload-log)
|
||||
(rtc-flows/trigger-rtc-start repo)))))))}
|
||||
"Use Logseq sync (Beta testing)"))
|
||||
(when (and remote? (or (and db-based? manager?) (not db-based?)))
|
||||
(shui/dropdown-menu-item
|
||||
{:key "delete-remotely"
|
||||
|
||||
@@ -197,7 +197,7 @@
|
||||
(let [download-logs-flow (accumulated-logs-flow *accumulated-download-logs)
|
||||
download-logs (hooks/use-flow-state download-logs-flow)]
|
||||
(when (seq download-logs)
|
||||
[:div.flex.flex-col.gap-1
|
||||
[:div.capitalize.flex.flex-col.gap-1
|
||||
(for [log download-logs]
|
||||
[:div (:message log)])])))
|
||||
|
||||
@@ -206,8 +206,8 @@
|
||||
(let [upload-logs-flow (accumulated-logs-flow *accumulated-upload-logs)
|
||||
upload-logs (hooks/use-flow-state upload-logs-flow)]
|
||||
(when (seq upload-logs)
|
||||
[:div
|
||||
(for [log upload-logs]
|
||||
[:div.capitalize.flex.flex-col.gap-1
|
||||
(for [log (reverse upload-logs)]
|
||||
[:div (:message log)])])))
|
||||
|
||||
(def ^:private downloading?-flow
|
||||
@@ -232,6 +232,14 @@
|
||||
(m/eduction (map (fn [log] (not= :upload-completed (:sub-type log)))))
|
||||
(c.m/continue-flow false)))
|
||||
|
||||
(defn on-upload-finished-task
|
||||
[on-success]
|
||||
(let [task (->> rtc-flows/rtc-upload-log-flow
|
||||
(m/reduce (fn [_ log]
|
||||
(when (= :upload-completed (:sub-type log))
|
||||
(on-success)))))]
|
||||
(task (fn []) (fn []))))
|
||||
|
||||
(rum/defc uploading-detail
|
||||
[]
|
||||
(when (true? (hooks/use-flow-state upload?-flow))
|
||||
|
||||
@@ -135,15 +135,7 @@
|
||||
(ldb/get-graph-rtc-uuid (db/get-db))
|
||||
(user-handler/logged-in?)
|
||||
(user-handler/team-member?))
|
||||
[:<>
|
||||
;; (rum/with-key (rtc-collaborators)
|
||||
;; (str "collab-" repo))
|
||||
(rtc-indicator/indicator)
|
||||
;; (when (user-handler/logged-in?)
|
||||
;; (rtc-indicator/downloading-detail))
|
||||
;; (when (user-handler/logged-in?)
|
||||
;; (rtc-indicator/uploading-detail))
|
||||
])]))))
|
||||
(rtc-indicator/indicator))]))))
|
||||
|
||||
;; main content
|
||||
(if db-restoring?
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
(reset! *last-popup-modal? false) pid)
|
||||
|
||||
:else
|
||||
(when (fn? content-fn)
|
||||
(when content-fn
|
||||
(mobile-state/set-popup! {:open? true
|
||||
:content-fn content-fn
|
||||
:opts opts})
|
||||
@@ -103,4 +103,4 @@
|
||||
[:h2.py-2.opacity-40 title])
|
||||
(when content-fn
|
||||
(mobile-ui/classic-app-container-wrap
|
||||
(content-fn)))]))))
|
||||
(if (fn? content-fn) (content-fn) content-fn)))]))))
|
||||
|
||||
Reference in New Issue
Block a user