Browse Source

Merge remote-tracking branch 'upstream/master' into whiteboards

Peng Xiao 3 years ago
parent
commit
f4ee3e2566

+ 2 - 2
android/app/build.gradle

@@ -6,8 +6,8 @@ android {
         applicationId "com.logseq.app"
         minSdkVersion rootProject.ext.minSdkVersion
         targetSdkVersion rootProject.ext.targetSdkVersion
-        versionCode 38
-        versionName "0.8.4"
+        versionCode 39
+        versionName "0.8.5"
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         aaptOptions {
              // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.

+ 4 - 4
ios/App/App.xcodeproj/project.pbxproj

@@ -547,7 +547,7 @@
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 0.8.3;
+				MARKETING_VERSION = 0.8.5;
 				OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -574,7 +574,7 @@
 				INFOPLIST_FILE = App/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
-				MARKETING_VERSION = 0.8.3;
+				MARKETING_VERSION = 0.8.5;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
@@ -599,7 +599,7 @@
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				MARKETING_VERSION = 0.8.3;
+				MARKETING_VERSION = 0.8.5;
 				MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
 				MTL_FAST_MATH = YES;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq.ShareViewController;
@@ -626,7 +626,7 @@
 				INFOPLIST_KEY_NSHumanReadableCopyright = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 13.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
-				MARKETING_VERSION = 0.8.3;
+				MARKETING_VERSION = 0.8.5;
 				MTL_FAST_MATH = YES;
 				PRODUCT_BUNDLE_IDENTIFIER = com.logseq.logseq.ShareViewController;
 				PRODUCT_NAME = "$(TARGET_NAME)";

+ 35 - 33
src/main/frontend/components/file_sync.cljs

@@ -340,39 +340,41 @@
 
    [:div.-mt-1
     (ui/button
-     (str "Open a local directory")
-     :class "w-full rounded-t-none py-4"
-     :on-click #(-> (page-handler/ls-dir-files!
-                     (fn [{:keys [url]}]
-                       (file-sync-handler/init-remote-graph url)
-                       ;; TODO: wait for switch done
-                       (js/setTimeout (fn [] (repo-handler/refresh-repos!)) 200))
-
-                     {:empty-dir?-or-pred
-                      (fn [ret]
-                        (let [empty-dir? (nil? (second ret))]
-                          (if-let [root (first ret)]
-
-                            ;; verify directory
-                            (-> (if empty-dir?
-                                  (p/resolved nil)
-                                  (if (util/electron?)
-                                    (ipc/ipc :readGraphTxIdInfo root)
-                                    (fs-util/read-graph-txid-info root)))
-
-                                (p/then (fn [^js info]
-                                          (when (and (not empty-dir?)
-                                                     (or (nil? info)
-                                                         (nil? (second info))
-                                                         (not= (second info) (:GraphUUID graph))))
-                                            (throw (js/Error. "AssertDirectoryError"))))))
-
-                            ;; cancel pick a directory
-                            (throw (js/Error. nil)))))})
-
-                    (p/catch (fn [^js e]
-                               (when (= "AssertDirectoryError" (.-message e))
-                                 (notifications/show! "Please select an empty directory or an existing remote graph!" :error))))))
+      (str "Open a local directory")
+      :class "w-full rounded-t-none py-4"
+      :on-click #(->
+                  (page-handler/ls-dir-files!
+                   (fn [{:keys [url]}]
+                     (file-sync-handler/init-remote-graph url)
+                     ;; TODO: wait for switch done
+                     (js/setTimeout (fn [] (repo-handler/refresh-repos!)) 200))
+
+                   {:empty-dir?-or-pred
+                    (fn [ret]
+                      (let [empty-dir? (nil? (second ret))]
+                        (if-let [root (first ret)]
+
+                          ;; verify directory
+                          (-> (if empty-dir?
+                                (p/resolved nil)
+                                (if (util/electron?)
+                                  (ipc/ipc :readGraphTxIdInfo root)
+                                  (fs-util/read-graph-txid-info root)))
+
+                              (p/then (fn [^js info]
+                                        (when (and (not empty-dir?)
+                                                   (or (nil? info)
+                                                       (nil? (second info))
+                                                       (not= (second info) (:GraphUUID graph))))
+                                          (if (js/confirm "This directory is not empty, are you sure to sync the remote graph to it? Make sure to back up the directory first.")
+                                            (do
+                                              (state/set-state! :graph/remote-binding? true)
+                                              (p/resolved nil))
+                                            (throw (js/Error. nil)))))))
+
+                          ;; cancel pick a directory
+                          (throw (js/Error. nil)))))})
+                  (p/catch (fn []))))
     [:p.text-xs.opacity-50.px-1 (ui/icon "alert-circle") " An empty directory or an existing remote graph!"]]])
 
 (defn pick-dest-to-sync-panel [graph]

+ 5 - 2
src/main/frontend/handler/events.cljs

@@ -147,8 +147,11 @@
      (graph-switch graph))))
 
 (defmethod handle :graph/switch [[_ graph opts]]
-  (if @outliner-file/*writes-finished?
-    (graph-switch-on-persisted graph opts)
+  (if (or @outliner-file/*writes-finished?
+          (:graph/remote-binding? @state/state))
+    (do
+      (state/set-state! :graph/remote-binding? false)
+      (graph-switch-on-persisted graph opts))
     (notification/show!
      "Please wait seconds until all changes are saved for the current graph."
      :warning)))

+ 1 - 1
src/main/frontend/version.cljs

@@ -1,3 +1,3 @@
 (ns frontend.version)
 
-(defonce version "0.8.4")
+(defonce version "0.8.5")