Przeglądaj źródła

Merge branch 'master' into improve-references-filter

Gabriel Horner 3 lat temu
rodzic
commit
9ee2a09601

+ 7 - 3
e2e-tests/page-search.spec.ts

@@ -68,9 +68,12 @@ async function alias_test(page: Page, page_name: string, search_kws: string[]) {
   await page.waitForTimeout(500)
 
   // build target Page with alias
+  // the target page will contains the content in 
+  //   alias_test_content_1,
+  //   alias_test_content_2, and
+  //   alias_test_content_3 sequentialy, to validate the target page state
   await page.type('textarea >> nth=0', 'alias:: [[' + alias_name)
-  await page.press('textarea >> nth=0', 'ArrowRight')
-  await page.press('textarea >> nth=0', 'ArrowRight')
+  await page.press('textarea >> nth=0', 'Enter') // Enter for finishing selection
   await page.press('textarea >> nth=0', 'Enter') // double Enter for exit property editing
   await page.press('textarea >> nth=0', 'Enter') // double Enter for exit property editing
   await page.waitForTimeout(500)
@@ -81,6 +84,7 @@ async function alias_test(page: Page, page_name: string, search_kws: string[]) {
   // create alias ref in origin Page
   await newBlock(page)
   await page.type('textarea >> nth=0', '[[' + alias_name)
+  await page.press('textarea >> nth=0', 'Enter') // Enter for finishing selection
   await page.waitForTimeout(100)
 
   await page.keyboard.press(hotkeyOpenLink)
@@ -157,6 +161,6 @@ async function alias_test(page: Page, page_name: string, search_kws: string[]) {
   // TODO: search clicking (alias property)
 }
 
-test.skip('page diacritic alias', async ({ page }) => {
+test('page diacritic alias', async ({ page }) => {
   await alias_test(page, "ü", ["ü", "ü", "Ü"])
 })

+ 6 - 4
ios/App/App/FsWatcher.swift

@@ -48,10 +48,12 @@ public class FsWatcher: CAPPlugin, PollingWatcherDelegate {
         // NOTE: Event in js {dir path content stat{mtime}}
         switch event {
         case .Unlink:
-            self.notifyListeners("watcher", data: ["event": "unlink",
-                                                   "dir": baseUrl?.description as Any,
-                                                   "path": url.description,
-                                                  ])
+            DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
+                self.notifyListeners("watcher", data: ["event": "unlink",
+                                                       "dir": self.baseUrl?.description as Any,
+                                                       "path": url.description,
+                                                      ])
+            }
         case .Add, .Change:
             var content: String? = nil
             if url.shouldNotifyWithContent() {

+ 4 - 1
src/electron/electron/fs_watcher.cljs

@@ -82,8 +82,11 @@
              (fn [path]
                (publish-file-event! dir path "change")))
         (.on dir-watcher "unlink"
+             ;; delay 500ms for syncing disks
              (fn [path]
-               (publish-file-event! dir path "unlink")))
+               (js/setTimeout #(when (not (fs/existsSync path))
+                                 (publish-file-event! dir path "unlink"))
+                              500)))
         (.on dir-watcher "error"
              (fn [path]
                (println "Watch error happened: "

+ 1 - 3
src/main/frontend/extensions/srs.cljs

@@ -441,9 +441,7 @@
         [:div.ls-card.content
          {:class (when (or preview? modal?)
                    (str (util/hiccup->class ".flex.flex-col.resize.overflow-y-auto")
-                        (when modal? " modal-cards")))
-          :on-mouse-down (fn [e]
-                           (util/stop e))}
+                        (when modal? " modal-cards")))}
          (let [repo (state/get-current-repo)]
            [:div {:style {:margin-top 20}}
             (component-block/breadcrumb {} repo root-block-id {})])

+ 4 - 2
src/main/frontend/handler.cljs

@@ -101,8 +101,10 @@
            (repo-handler/setup-local-repo-if-not-exists!)
 
            :else
-           (state/set-db-restoring! false))
-
+           (state/set-db-restoring! false))))
+      (p/then
+       (fn []
+         (prn "db restored, setting up repo hooks")
          (store-schema!)
 
          (state/pub-event! [:modal/nfs-ask-permission])

+ 13 - 2
src/main/frontend/handler/repo.cljs

@@ -348,8 +348,9 @@
   (state/set-current-repo! repo)
   (db/start-db-conn! repo))
 
-(defn setup-local-repo-if-not-exists!
+(defn- setup-local-repo-if-not-exists-impl!
   []
+  ;; loop query if js/window.pfs is ready, interval 100ms
   (if js/window.pfs
     (let [repo config/local-repo]
       (p/do! (fs/mkdir-if-not-exists (str "/" repo))
@@ -367,7 +368,17 @@
              (create-custom-theme repo)
              (state/set-db-restoring! false)
              (ui-handler/re-render-root!)))
-    (js/setTimeout setup-local-repo-if-not-exists! 100)))
+    (p/then (p/delay 100) ;; TODO Junyi remove the string
+            setup-local-repo-if-not-exists-impl!)))
+
+(defn setup-local-repo-if-not-exists!
+  []
+  ;; ensure `(state/set-db-restoring! false)` at exit
+  (-> (setup-local-repo-if-not-exists-impl!)
+      (p/timeout 3000)
+      (p/catch (fn []
+                 (state/set-db-restoring! false)
+                 (prn "setup-local-repo failed! timeout 3000ms")))))
 
 (defn restore-and-setup-repo!
   "Restore the db of a graph from the persisted data, and setup. Create a new