Skip to content

Commit 2801130

Browse files
committed
fix(mobile): duplicate assets created when sharing to mobile
1 parent 666c50f commit 2801130

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/main/frontend/mobile/intent.cljs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,8 @@
178178
file (some-> file-base64-str (util/base64string-to-unit8array)
179179
(vector) (clj->js) (js/File. basename #js {}))
180180
result (editor-handler/db-based-save-assets!
181-
(state/get-current-repo) [file] {})
182-
asset-entity (first result)
183-
url-link (util/format "[[%s]]" (:block/uuid asset-entity))]
184-
url-link)
181+
(state/get-current-repo) [file] {})]
182+
result)
185183
(p/catch #(log/error :handle-asset-file %))))
186184

187185
(defn- handle-payload-resource
@@ -223,14 +221,21 @@
223221

224222
template (get-in (state/get-config)
225223
[:quick-capture-templates :text]
226-
"**{time}** [[quick capture]]: {text} {url}")
224+
"**{time}** [[quick capture]] {text} {url}")
227225
{:keys [text resources]} payload
228226
text (or text "")
229227
rich-content (-> (p/all (map (fn [resource]
230228
(handle-payload-resource resource format))
231229
resources))
232-
(p/then (partial string/join "\n")))]
233-
(when (or (not-empty text) (not-empty rich-content))
230+
(p/then (fn [result]
231+
(when (every? string? result)
232+
(string/join "\n" result)))))]
233+
(when (and (or (not-empty text) (not-empty rich-content))
234+
(not (every?
235+
(fn [resource]
236+
(contains? (set/union config/doc-formats config/media-formats)
237+
(keyword (:ext resource))))
238+
resources)))
234239
(let [time (date/get-current-time)
235240
date-ref-name (date/today)
236241
content (-> template

0 commit comments

Comments
 (0)