mirror of https://github.com/logseq/logseq
fix: disable creating remote graph when sync is not started yet
Also, don't show `password is required` when starting the sync.pull/6731/head
parent
14e87963ef
commit
376cda0bd3
|
@ -182,11 +182,12 @@
|
||||||
|
|
||||||
status (:state sync-state)
|
status (:state sync-state)
|
||||||
status (or (nil? status) (keyword (name status)))
|
status (or (nil? status) (keyword (name status)))
|
||||||
off? (file-sync-handler/sync-off? sync-state)
|
off? (fs-sync/sync-off? sync-state)
|
||||||
full-syncing? (contains? #{:local->remote-full-sync :remote->local-full-sync} status)
|
full-syncing? (contains? #{:local->remote-full-sync :remote->local-full-sync} status)
|
||||||
syncing? (or full-syncing? (contains? #{:local->remote :remote->local} status))
|
syncing? (or full-syncing? (contains? #{:local->remote :remote->local} status))
|
||||||
idle? (contains? #{:idle} status)
|
idle? (contains? #{:idle} status)
|
||||||
need-password? (contains? #{:need-password} status)
|
need-password? (and (contains? #{:need-password} status)
|
||||||
|
(not (fs-sync/graph-encrypted?)))
|
||||||
queuing? (and idle? (boolean (seq queuing-files)))
|
queuing? (and idle? (boolean (seq queuing-files)))
|
||||||
no-active-files? (empty? (concat downloading-files queuing-files uploading-files))
|
no-active-files? (empty? (concat downloading-files queuing-files uploading-files))
|
||||||
create-remote-graph-fn #(when (and current-repo (not (config/demo-graph? current-repo)))
|
create-remote-graph-fn #(when (and current-repo (not (config/demo-graph? current-repo)))
|
||||||
|
@ -198,7 +199,9 @@
|
||||||
(create-remote-graph-panel current-repo graph-name close-fn))]
|
(create-remote-graph-panel current-repo graph-name close-fn))]
|
||||||
|
|
||||||
(state/set-modal! confirm-fn {:center? true :close-btn? false})))
|
(state/set-modal! confirm-fn {:center? true :close-btn? false})))
|
||||||
turn-on #(async/go
|
turn-on (fn []
|
||||||
|
(when-not (file-sync-handler/current-graph-sync-on?)
|
||||||
|
(async/go
|
||||||
(async/<! (p->c (persist-var/-load fs-sync/graphs-txid)))
|
(async/<! (p->c (persist-var/-load fs-sync/graphs-txid)))
|
||||||
(cond
|
(cond
|
||||||
@*beta-unavailable?
|
@*beta-unavailable?
|
||||||
|
@ -211,12 +214,11 @@
|
||||||
nil
|
nil
|
||||||
|
|
||||||
(and synced-file-graph?
|
(and synced-file-graph?
|
||||||
(file-sync-handler/graph-sync-off? current-repo)
|
(fs-sync/graph-sync-off? current-repo)
|
||||||
(second @fs-sync/graphs-txid)
|
(second @fs-sync/graphs-txid)
|
||||||
(async/<! (fs-sync/<check-remote-graph-exists (second @fs-sync/graphs-txid))))
|
(async/<! (fs-sync/<check-remote-graph-exists (second @fs-sync/graphs-txid))))
|
||||||
(fs-sync/sync-start)
|
(fs-sync/sync-start)
|
||||||
|
|
||||||
|
|
||||||
;; remote graph already has been deleted, clear repos first, then create-remote-graph
|
;; remote graph already has been deleted, clear repos first, then create-remote-graph
|
||||||
synced-file-graph? ; <check-remote-graph-exists -> false
|
synced-file-graph? ; <check-remote-graph-exists -> false
|
||||||
(do (state/set-repos!
|
(do (state/set-repos!
|
||||||
|
@ -227,8 +229,11 @@
|
||||||
(state/get-repos)))
|
(state/get-repos)))
|
||||||
(create-remote-graph-fn))
|
(create-remote-graph-fn))
|
||||||
|
|
||||||
|
(second @fs-sync/graphs-txid) ; sync not started yet
|
||||||
|
nil
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(create-remote-graph-fn)))]
|
(create-remote-graph-fn)))))]
|
||||||
|
|
||||||
(if creating-remote-graph?
|
(if creating-remote-graph?
|
||||||
(ui/loading "")
|
(ui/loading "")
|
||||||
|
@ -262,7 +267,7 @@
|
||||||
(if need-password?
|
(if need-password?
|
||||||
[{:title [:div.file-item
|
[{:title [:div.file-item
|
||||||
(ui/icon "lock") "Password is required"]
|
(ui/icon "lock") "Password is required"]
|
||||||
:options {:on-click #(state/pub-event! [:file-sync/restart])}}]
|
:options {:on-click fs-sync/sync-need-password!}}]
|
||||||
[{:title [:div.file-item.is-first ""]
|
[{:title [:div.file-item.is-first ""]
|
||||||
:options {:class "is-first-placeholder"}}]))
|
:options {:class "is-first-placeholder"}}]))
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,9 @@
|
||||||
::local->remote-full-sync
|
::local->remote-full-sync
|
||||||
;; remote->local full sync
|
;; remote->local full sync
|
||||||
::remote->local-full-sync
|
::remote->local-full-sync
|
||||||
::stop
|
;; snapshot state when switching between apps on iOS
|
||||||
::pause})
|
::pause
|
||||||
|
::stop})
|
||||||
(s/def ::path string?)
|
(s/def ::path string?)
|
||||||
(s/def ::time t/date?)
|
(s/def ::time t/date?)
|
||||||
(s/def ::remote->local-type #{:delete :update
|
(s/def ::remote->local-type #{:delete :update
|
||||||
|
@ -1679,6 +1680,10 @@
|
||||||
[graph-uuid]
|
[graph-uuid]
|
||||||
(js/localStorage.removeItem (local-storage-pwd-path graph-uuid)))
|
(js/localStorage.removeItem (local-storage-pwd-path graph-uuid)))
|
||||||
|
|
||||||
|
(defn get-pwd
|
||||||
|
[graph-uuid]
|
||||||
|
(js/localStorage.getItem (local-storage-pwd-path graph-uuid)))
|
||||||
|
|
||||||
(defn remove-all-pwd!
|
(defn remove-all-pwd!
|
||||||
[]
|
[]
|
||||||
(doseq [k (filter #(string/starts-with? % "encrypted-pwd/") (js->clj (js-keys js/localStorage)))]
|
(doseq [k (filter #(string/starts-with? % "encrypted-pwd/") (js->clj (js-keys js/localStorage)))]
|
||||||
|
@ -1706,7 +1711,7 @@
|
||||||
"restore pwd from persisted encrypted-pwd, update `pwd-map`"
|
"restore pwd from persisted encrypted-pwd, update `pwd-map`"
|
||||||
[graph-uuid]
|
[graph-uuid]
|
||||||
(go
|
(go
|
||||||
(let [encrypted-pwd (js/localStorage.getItem (local-storage-pwd-path graph-uuid))]
|
(let [encrypted-pwd (get-pwd graph-uuid)]
|
||||||
(if (nil? encrypted-pwd)
|
(if (nil? encrypted-pwd)
|
||||||
{:restore-pwd-failed true}
|
{:restore-pwd-failed true}
|
||||||
(let [[salt-value _expired-at gone?]
|
(let [[salt-value _expired-at gone?]
|
||||||
|
@ -2713,6 +2718,11 @@
|
||||||
(state/set-file-sync-manager nil))
|
(state/set-file-sync-manager nil))
|
||||||
(reset! current-sm-graph-uuid nil)))
|
(reset! current-sm-graph-uuid nil)))
|
||||||
|
|
||||||
|
(defn sync-need-password!
|
||||||
|
[]
|
||||||
|
(when-let [sm ^SyncManager (state/get-file-sync-manager)]
|
||||||
|
(.need-password sm)))
|
||||||
|
|
||||||
(defn check-graph-belong-to-current-user
|
(defn check-graph-belong-to-current-user
|
||||||
[current-user-uuid graph-user-uuid]
|
[current-user-uuid graph-user-uuid]
|
||||||
(cond
|
(cond
|
||||||
|
@ -2746,17 +2756,29 @@
|
||||||
(notification/show! (t :file-sync/graph-deleted) :warning false))
|
(notification/show! (t :file-sync/graph-deleted) :warning false))
|
||||||
result)))
|
result)))
|
||||||
|
|
||||||
|
(defn sync-off?
|
||||||
|
[sync-state]
|
||||||
|
(or (nil? sync-state) (sync-state--stopped? sync-state)))
|
||||||
|
|
||||||
|
(defn graph-sync-off?
|
||||||
|
"Is sync not running for this `graph`?"
|
||||||
|
[graph]
|
||||||
|
(sync-off? (state/get-file-sync-state graph)))
|
||||||
|
|
||||||
|
(defn graph-encrypted?
|
||||||
|
[]
|
||||||
|
(when-let [graph-uuid (second @graphs-txid)]
|
||||||
|
(get-pwd graph-uuid)))
|
||||||
|
|
||||||
(declare network-online-cursor)
|
(declare network-online-cursor)
|
||||||
|
|
||||||
(defn sync-start []
|
(defn sync-start []
|
||||||
(let [*sync-state (atom (sync-state))
|
(let [*sync-state (atom (sync-state))
|
||||||
current-user-uuid (user/user-uuid)
|
current-user-uuid (user/user-uuid)
|
||||||
repo (state/get-current-repo)]
|
repo (state/get-current-repo)]
|
||||||
|
(when (graph-sync-off? repo)
|
||||||
(go
|
(go
|
||||||
(when @network-online-cursor
|
(when @network-online-cursor
|
||||||
;; stop previous sync
|
|
||||||
(<! (<sync-stop))
|
|
||||||
|
|
||||||
(<! (p->c (persist-var/-load graphs-txid)))
|
(<! (p->c (persist-var/-load graphs-txid)))
|
||||||
|
|
||||||
(let [[user-uuid graph-uuid txid] @graphs-txid]
|
(let [[user-uuid graph-uuid txid] @graphs-txid]
|
||||||
|
@ -2782,7 +2804,7 @@
|
||||||
(.start sm)
|
(.start sm)
|
||||||
|
|
||||||
(offer! remote->local-full-sync-chan true)
|
(offer! remote->local-full-sync-chan true)
|
||||||
(offer! full-sync-chan true)))))))))))
|
(offer! full-sync-chan true))))))))))))
|
||||||
|
|
||||||
;;; ### some add-watches
|
;;; ### some add-watches
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
(vector? (:sync-meta %))
|
(vector? (:sync-meta %))
|
||||||
(util/uuid-string? (first (:sync-meta %)))
|
(util/uuid-string? (first (:sync-meta %)))
|
||||||
(util/uuid-string? (second (:sync-meta %)))) repos)
|
(util/uuid-string? (second (:sync-meta %)))) repos)
|
||||||
(file-sync-restart!)))))
|
(sync/sync-start)))))
|
||||||
(file-sync/maybe-onboarding-show status)))))))
|
(file-sync/maybe-onboarding-show status)))))))
|
||||||
|
|
||||||
(defmethod handle :user/logout [[_]]
|
(defmethod handle :user/logout [[_]]
|
||||||
|
@ -639,9 +639,6 @@
|
||||||
(notification/show! "file sync graph count exceed limit" :warning false)
|
(notification/show! "file sync graph count exceed limit" :warning false)
|
||||||
(file-sync-stop!))
|
(file-sync-stop!))
|
||||||
|
|
||||||
(defmethod handle :file-sync/restart [[_]]
|
|
||||||
(file-sync-restart!))
|
|
||||||
|
|
||||||
(defmethod handle :graph/restored [[_ _graph]]
|
(defmethod handle :graph/restored [[_ _graph]]
|
||||||
(mobile/init!)
|
(mobile/init!)
|
||||||
(when-not (mobile-util/native-ios?)
|
(when-not (mobile-util/native-ios?)
|
||||||
|
|
|
@ -205,11 +205,3 @@
|
||||||
(defn reset-user-state! []
|
(defn reset-user-state! []
|
||||||
(vreset! *beta-unavailable? false)
|
(vreset! *beta-unavailable? false)
|
||||||
(state/set-state! :file-sync/onboarding-state nil))
|
(state/set-state! :file-sync/onboarding-state nil))
|
||||||
|
|
||||||
(defn sync-off?
|
|
||||||
[sync-state]
|
|
||||||
(or (nil? sync-state) (sync/sync-state--stopped? sync-state)))
|
|
||||||
|
|
||||||
(defn graph-sync-off?
|
|
||||||
[graph]
|
|
||||||
(sync-off? (state/get-file-sync-state graph)))
|
|
||||||
|
|
Loading…
Reference in New Issue