mirror of
https://github.com/penpot/penpot.git
synced 2025-01-22 14:39:45 -05:00
🐛 Fix custom font upload fails silently for unsupported formats
This commit is contained in:
parent
ac3251b29e
commit
88cd19d21a
5 changed files with 44 additions and 10 deletions
|
@ -44,6 +44,7 @@
|
|||
- Fix boards grouped shouldn't show the title [Taiga #4251](https://tree.taiga.io/project/penpot/issue/4251)
|
||||
- Fix gradient handlers are under resize handlers[Taiga #4298](https://tree.taiga.io/project/penpot/issue/4298)
|
||||
- Fix grid not syncing immediately in multiuser [Taiga #4339](https://tree.taiga.io/project/penpot/issue/4339)
|
||||
- Fix custom font upload fails silently for unsupported formats [Taiga #4279](https://tree.taiga.io/project/penpot/issue/4280)
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
### :heart: Community contributions by (Thank you!)
|
||||
|
|
|
@ -12,8 +12,11 @@
|
|||
[app.common.media :as cm]
|
||||
[app.common.spec :as us]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.messages :as dm]
|
||||
[app.main.fonts :as fonts]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.store :as st]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[app.util.storage :refer [storage]]
|
||||
[app.util.webapi :as wa]
|
||||
[beicon.core :as rx]
|
||||
|
@ -133,17 +136,35 @@
|
|||
{:data data
|
||||
:name (.-name blob)
|
||||
:type (parse-mtype data)}))
|
||||
(rx/mapcat (fn [{:keys [type] :as font}]
|
||||
(if type
|
||||
(rx/catch (fn []
|
||||
(rx/of {:error (.-name blob)})))
|
||||
(rx/mapcat (fn [{:keys [type, error] :as font}]
|
||||
(if (or type error)
|
||||
(rx/of font)
|
||||
(rx/empty))))))]
|
||||
|
||||
(->> (rx/from blobs)
|
||||
(rx/mapcat read-blob)
|
||||
(rx/map parse-font)
|
||||
(rx/filter some?)
|
||||
(rx/map prepare)
|
||||
(rx/reduce join {}))))
|
||||
(let [fonts (->> (rx/from blobs)
|
||||
(rx/mapcat read-blob))
|
||||
errors (->> fonts
|
||||
(rx/filter #(some? (:error %)))
|
||||
(rx/reduce (fn [acc font]
|
||||
(conj acc (str "'" (:error font) "'")))
|
||||
[]))]
|
||||
|
||||
(rx/subscribe errors
|
||||
#(when
|
||||
(not-empty %)
|
||||
(st/emit!
|
||||
(dm/error
|
||||
(if (> (count %) 1)
|
||||
(tr "errors.bad-font-plural" (str/join ", " %))
|
||||
(tr "errors.bad-font" (first %)))))))
|
||||
(->> fonts
|
||||
(rx/filter #(nil? (:error %)))
|
||||
(rx/map parse-font)
|
||||
(rx/filter some?)
|
||||
(rx/map prepare)
|
||||
(rx/reduce join {})))))
|
||||
|
||||
(defn- calculate-family-to-id-mapping
|
||||
[existing]
|
||||
|
|
|
@ -303,8 +303,7 @@
|
|||
[:div.table-field.search-input
|
||||
[:input {:placeholder (tr "labels.search-font")
|
||||
:default-value ""
|
||||
:on-change on-change
|
||||
}]]]
|
||||
:on-change on-change}]]]
|
||||
|
||||
(cond
|
||||
(seq fonts)
|
||||
|
|
|
@ -4558,3 +4558,10 @@ msgstr "Click to close the path"
|
|||
|
||||
msgid "errors.profile-blocked"
|
||||
msgstr "The profile is blocked"
|
||||
|
||||
msgid "errors.bad-font"
|
||||
msgstr "The font %s could not be loaded"
|
||||
|
||||
msgid "errors.bad-font-plural"
|
||||
msgstr "The fonts %s could not be loaded"
|
||||
|
||||
|
|
|
@ -4765,3 +4765,9 @@ msgstr "Pulsar para cerrar la ruta"
|
|||
|
||||
msgid "errors.profile-blocked"
|
||||
msgstr "El perfil esta blockeado"
|
||||
|
||||
msgid "errors.bad-font"
|
||||
msgstr "No se ha podido cargar la fuente %s"
|
||||
|
||||
msgid "errors.bad-font-plural"
|
||||
msgstr "No se han podido cargar las fuentes %s"
|
||||
|
|
Loading…
Add table
Reference in a new issue