Skip to content

Commit edb9f91

Browse files
committed
enhance: save record audio to quick add when capture
1 parent 489f7af commit edb9f91

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/main/frontend/handler/editor.cljs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,7 +1579,7 @@
15791579
"Save incoming(pasted) assets to assets directory.
15801580
15811581
Returns: asset entities"
1582-
[repo files & {:keys [pdf-area? last-edit-block]}]
1582+
[repo files & {:keys [pdf-area? last-edit-block save-to-page]}]
15831583
(p/let [[repo-dir asset-dir-rpath] (assets-handler/ensure-assets-dir! repo)
15841584
today-page-name (date/today)
15851585
today-page-e (db-model/get-journal-page today-page-name)
@@ -1592,8 +1592,12 @@
15921592
blocks (remove nil? blocks*)
15931593
edit-block (or (state/get-edit-block) last-edit-block)
15941594
insert-to-current-block-page? (and (:block/uuid edit-block) (not pdf-area?))
1595-
target (if insert-to-current-block-page?
1595+
target (cond
1596+
insert-to-current-block-page?
15961597
edit-block
1598+
save-to-page
1599+
save-to-page
1600+
:else
15971601
today-page)]
15981602
(when-not target
15991603
(throw (ex-info "invalid target" {:files files
@@ -1604,6 +1608,7 @@
16041608
(ui-outliner-tx/transact!
16051609
{:outliner-op :insert-blocks}
16061610
(outliner-op/insert-blocks! blocks target {:keep-uuid? true
1611+
:bottom? true
16071612
:sibling? (= edit-block target)
16081613
:replace-empty-target? true}))
16091614
(map (fn [b] (db/entity [:block/uuid (:block/uuid b)])) blocks)))))

src/main/mobile/components/recorder.cljs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
[cljs-time.local :as tl]
66
[clojure.string :as string]
77
[frontend.date :as date]
8+
[frontend.db :as db]
89
[frontend.db.model :as db-model]
910
[frontend.handler.editor :as editor-handler]
1011
[frontend.mobile.util :as mobile-util]
1112
[frontend.state :as state]
1213
[frontend.util :as util]
1314
[goog.functions :as gfun]
1415
[lambdaisland.glogi :as log]
16+
[logseq.common.config :as common-config]
17+
[logseq.db :as ldb]
1518
[logseq.shui.hooks :as hooks]
1619
[logseq.shui.ui :as shui]
1720
[mobile.init :as init]
@@ -62,9 +65,12 @@
6265
{:formatter-str audio-file-format})
6366
"."))]
6467
(p/let [file (js/File. [blob] filename #js {:type (.-type blob)})
65-
result (editor-handler/db-based-save-assets! (state/get-current-repo)
66-
[file]
67-
{:last-edit-block @*last-edit-block})
68+
capture? (= "capture" @mobile-state/*tab)
69+
insert-opts (cond->
70+
{:last-edit-block @*last-edit-block}
71+
capture?
72+
(assoc :save-to-page (ldb/get-built-in-page (db/get-db) common-config/quick-add-page-name)))
73+
result (editor-handler/db-based-save-assets! (state/get-current-repo) [file] insert-opts)
6874
asset-entity (first result)]
6975
(when (nil? asset-entity)
7076
(log/error ::empty-asset-entity {}))

0 commit comments

Comments
 (0)