Bläddra i källkod

enhance: save record audio to quick add when capture

Tienson Qin 3 dagar sedan
förälder
incheckning
edb9f914c3
2 ändrade filer med 16 tillägg och 5 borttagningar
  1. 7 2
      src/main/frontend/handler/editor.cljs
  2. 9 3
      src/main/mobile/components/recorder.cljs

+ 7 - 2
src/main/frontend/handler/editor.cljs

@@ -1579,7 +1579,7 @@
   "Save incoming(pasted) assets to assets directory.
 
    Returns: asset entities"
-  [repo files & {:keys [pdf-area? last-edit-block]}]
+  [repo files & {:keys [pdf-area? last-edit-block save-to-page]}]
   (p/let [[repo-dir asset-dir-rpath] (assets-handler/ensure-assets-dir! repo)
           today-page-name (date/today)
           today-page-e (db-model/get-journal-page today-page-name)
@@ -1592,8 +1592,12 @@
           blocks (remove nil? blocks*)
           edit-block (or (state/get-edit-block) last-edit-block)
           insert-to-current-block-page? (and (:block/uuid edit-block) (not pdf-area?))
-          target (if insert-to-current-block-page?
+          target (cond
+                   insert-to-current-block-page?
                    edit-block
+                   save-to-page
+                   save-to-page
+                   :else
                    today-page)]
     (when-not target
       (throw (ex-info "invalid target" {:files files
@@ -1604,6 +1608,7 @@
        (ui-outliner-tx/transact!
         {:outliner-op :insert-blocks}
         (outliner-op/insert-blocks! blocks target {:keep-uuid? true
+                                                   :bottom? true
                                                    :sibling? (= edit-block target)
                                                    :replace-empty-target? true}))
        (map (fn [b] (db/entity [:block/uuid (:block/uuid b)])) blocks)))))

+ 9 - 3
src/main/mobile/components/recorder.cljs

@@ -5,6 +5,7 @@
             [cljs-time.local :as tl]
             [clojure.string :as string]
             [frontend.date :as date]
+            [frontend.db :as db]
             [frontend.db.model :as db-model]
             [frontend.handler.editor :as editor-handler]
             [frontend.mobile.util :as mobile-util]
@@ -12,6 +13,8 @@
             [frontend.util :as util]
             [goog.functions :as gfun]
             [lambdaisland.glogi :as log]
+            [logseq.common.config :as common-config]
+            [logseq.db :as ldb]
             [logseq.shui.hooks :as hooks]
             [logseq.shui.ui :as shui]
             [mobile.init :as init]
@@ -62,9 +65,12 @@
                                            {:formatter-str audio-file-format})
                                           "."))]
       (p/let [file (js/File. [blob] filename #js {:type (.-type blob)})
-              result (editor-handler/db-based-save-assets! (state/get-current-repo)
-                                                           [file]
-                                                           {:last-edit-block @*last-edit-block})
+              capture? (= "capture" @mobile-state/*tab)
+              insert-opts (cond->
+                           {:last-edit-block @*last-edit-block}
+                            capture?
+                            (assoc :save-to-page (ldb/get-built-in-page (db/get-db) common-config/quick-add-page-name)))
+              result (editor-handler/db-based-save-assets! (state/get-current-repo) [file] insert-opts)
               asset-entity (first result)]
         (when (nil? asset-entity)
           (log/error ::empty-asset-entity {}))