0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-04 13:29:14 -05:00

Merge pull request #2458 from penpot/palba-upload-font-fails-silent2

🐛 Fix custom font upload fails silently for unsupported formats
This commit is contained in:
Eva Marco 2022-10-17 13:16:32 +02:00 committed by GitHub
commit 5c8710b8cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 10 deletions

View file

@ -44,6 +44,7 @@
- Fix boards grouped shouldn't show the title [Taiga #4251](https://tree.taiga.io/project/penpot/issue/4251) - 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 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 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 ### :arrow_up: Deps updates
### :heart: Community contributions by (Thank you!) ### :heart: Community contributions by (Thank you!)

View file

@ -12,8 +12,11 @@
[app.common.media :as cm] [app.common.media :as cm]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.messages :as dm]
[app.main.fonts :as fonts] [app.main.fonts :as fonts]
[app.main.repo :as rp] [app.main.repo :as rp]
[app.main.store :as st]
[app.util.i18n :refer [tr]]
[app.util.storage :refer [storage]] [app.util.storage :refer [storage]]
[app.util.webapi :as wa] [app.util.webapi :as wa]
[beicon.core :as rx] [beicon.core :as rx]
@ -133,17 +136,35 @@
{:data data {:data data
:name (.-name blob) :name (.-name blob)
:type (parse-mtype data)})) :type (parse-mtype data)}))
(rx/mapcat (fn [{:keys [type] :as font}] (rx/catch (fn []
(if type (rx/of {:error (.-name blob)})))
(rx/mapcat (fn [{:keys [type, error] :as font}]
(if (or type error)
(rx/of font) (rx/of font)
(rx/empty))))))] (rx/empty))))))]
(->> (rx/from blobs) (let [fonts (->> (rx/from blobs)
(rx/mapcat read-blob) (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/map parse-font)
(rx/filter some?) (rx/filter some?)
(rx/map prepare) (rx/map prepare)
(rx/reduce join {})))) (rx/reduce join {})))))
(defn- calculate-family-to-id-mapping (defn- calculate-family-to-id-mapping
[existing] [existing]

View file

@ -303,8 +303,7 @@
[:div.table-field.search-input [:div.table-field.search-input
[:input {:placeholder (tr "labels.search-font") [:input {:placeholder (tr "labels.search-font")
:default-value "" :default-value ""
:on-change on-change :on-change on-change}]]]
}]]]
(cond (cond
(seq fonts) (seq fonts)

View file

@ -4558,3 +4558,10 @@ msgstr "Click to close the path"
msgid "errors.profile-blocked" msgid "errors.profile-blocked"
msgstr "The profile is 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"

View file

@ -4765,3 +4765,9 @@ msgstr "Pulsar para cerrar la ruta"
msgid "errors.profile-blocked" msgid "errors.profile-blocked"
msgstr "El perfil esta blockeado" 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"