Browse Source

fix(electron): quick captured text is cleared when editing current

Andelf 3 years ago
parent
commit
a1b731a77a
1 changed files with 8 additions and 6 deletions
  1. 8 6
      src/main/electron/listener.cljs

+ 8 - 6
src/main/electron/listener.cljs

@@ -161,8 +161,8 @@
                                                    [:quick-capture-options :insert-today?]
                                                    false)
                              redirect-page? (get-in (state/get-config)
-                                                   [:quick-capture-options :redirect-page?]
-                                                   false)
+                                                    [:quick-capture-options :redirect-page?]
+                                                    false)
                              today-page (when (state/enable-journals?)
                                           (string/lower-case (date/today)))
                              page (if (or (= page "TODAY")
@@ -197,12 +197,14 @@
                              (editor-handler/insert (str "\n" content)))
 
                            (do
+                             (editor-handler/escape-editing)
                              (when (not= page (state/get-current-page))
                                (page-handler/create! page {:redirect? redirect-page?}))
-                             (editor-handler/escape-editing)
-                             (editor-handler/api-insert-new-block! content {:page page
-                                                                            :edit-block? true
-                                                                            :replace-empty-target? true}))))))
+                             ;; Or else this will clear the newly inserted content
+                             (js/setTimeout #(editor-handler/api-insert-new-block! content {:page page
+                                                                                            :edit-block? true
+                                                                                            :replace-empty-target? true})
+                                            100))))))
 
   (js/window.apis.on "openNewWindowOfGraph"
                      ;; Handle open new window in renderer, until the destination graph doesn't rely on setting local storage