mirror of
https://github.com/penpot/penpot.git
synced 2025-02-10 09:08:31 -05:00
✨ Show info while loading images
This commit is contained in:
parent
e3e8180b7a
commit
bac35853d3
3 changed files with 27 additions and 18 deletions
|
@ -546,13 +546,13 @@
|
|||
}
|
||||
},
|
||||
"errors.image-format-unsupported" : {
|
||||
"used-in" : [ "src/uxbox/main/data/images.cljs:375", "src/uxbox/main/data/workspace/persistence.cljs:320" ],
|
||||
"used-in" : [ "src/uxbox/main/data/images.cljs:375", "src/uxbox/main/data/workspace/persistence.cljs:318" ],
|
||||
"translations" : {
|
||||
"en" : "The image format is not supported (must be svg, jpg or png)."
|
||||
}
|
||||
},
|
||||
"errors.image-too-large" : {
|
||||
"used-in" : [ "src/uxbox/main/data/images.cljs:373", "src/uxbox/main/data/workspace/persistence.cljs:318" ],
|
||||
"used-in" : [ "src/uxbox/main/data/images.cljs:373", "src/uxbox/main/data/workspace/persistence.cljs:316" ],
|
||||
"translations" : {
|
||||
"en" : "The image is too large to be inserted (must be under 5mb)."
|
||||
}
|
||||
|
@ -585,7 +585,7 @@
|
|||
}
|
||||
},
|
||||
"errors.unexpected-error" : {
|
||||
"used-in" : [ "src/uxbox/main/data/images.cljs:382", "src/uxbox/main/data/workspace/persistence.cljs:333", "src/uxbox/main/ui/auth/register.cljs:54", "src/uxbox/main/ui/settings/change_email.cljs:42" ],
|
||||
"used-in" : [ "src/uxbox/main/data/images.cljs:384", "src/uxbox/main/data/workspace/persistence.cljs:327", "src/uxbox/main/ui/auth/register.cljs:54", "src/uxbox/main/ui/settings/change_email.cljs:42" ],
|
||||
"translations" : {
|
||||
"en" : "An unexpected error occurred.",
|
||||
"fr" : "Une erreur inattendue c'est produite"
|
||||
|
@ -625,6 +625,12 @@
|
|||
},
|
||||
"unused" : true
|
||||
},
|
||||
"image.loading" : {
|
||||
"used-in" : [ "src/uxbox/main/data/images.cljs:392", "src/uxbox/main/data/workspace/persistence.cljs:335" ],
|
||||
"translations" : {
|
||||
"en" : "Loading image..."
|
||||
}
|
||||
},
|
||||
"image.new" : {
|
||||
"translations" : {
|
||||
"en" : "New image",
|
||||
|
|
|
@ -375,11 +375,13 @@
|
|||
(throw (ex-info (tr "errors.image-format-unsupported") {})))
|
||||
file)
|
||||
|
||||
on-success on-uploaded
|
||||
on-success #(do (st/emit! dm/hide)
|
||||
(on-uploaded %))
|
||||
|
||||
on-error #(if (.-message %)
|
||||
(rx/of (dm/error (.-message %)))
|
||||
(rx/of (dm/error (tr "errors.unexpected-error"))))
|
||||
on-error #(do (st/emit! dm/hide)
|
||||
(if (.-message %)
|
||||
(rx/of (dm/error (.-message %)))
|
||||
(rx/of (dm/error (tr "errors.unexpected-error")))))
|
||||
|
||||
prepare
|
||||
(fn [file]
|
||||
|
@ -387,6 +389,10 @@
|
|||
:library-id library-id
|
||||
:content file})]
|
||||
|
||||
(st/emit! (dm/show {:content (tr "image.loading")
|
||||
:type :info
|
||||
:timeout nil}))
|
||||
|
||||
(->> (rx/from files)
|
||||
(rx/map check-file)
|
||||
(rx/map prepare)
|
||||
|
|
|
@ -305,13 +305,11 @@
|
|||
([file on-uploaded]
|
||||
(us/verify fn? on-uploaded)
|
||||
(ptk/reify ::upload-image
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc-in state [:workspace-local :uploading] true))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [check-file
|
||||
(let [file-id (get-in state [:workspace-page :file-id])
|
||||
|
||||
check-file
|
||||
(fn [file]
|
||||
(when (> (.-size file) max-file-size)
|
||||
(throw (ex-info (tr "errors.image-too-large") {})))
|
||||
|
@ -319,14 +317,10 @@
|
|||
(throw (ex-info (tr "errors.image-format-unsupported") {})))
|
||||
file)
|
||||
|
||||
finalize-upload #(assoc-in % [:workspace-local :uploading] false)
|
||||
|
||||
file-id (get-in state [:workspace-page :file-id])
|
||||
|
||||
on-success #(do (st/emit! finalize-upload)
|
||||
on-success #(do (st/emit! dm/hide)
|
||||
(on-uploaded %))
|
||||
|
||||
on-error #(do (st/emit! finalize-upload)
|
||||
on-error #(do (st/emit! dm/hide)
|
||||
(if (.-message %)
|
||||
(rx/of (dm/error (.-message %)))
|
||||
(rx/of (dm/error (tr "errors.unexpected-error")))))
|
||||
|
@ -337,6 +331,9 @@
|
|||
:file-id file-id
|
||||
:content file})]
|
||||
|
||||
(st/emit! (dm/show {:content (tr "image.loading")
|
||||
:type :info
|
||||
:timeout nil}))
|
||||
(->> (rx/of file)
|
||||
(rx/map check-file)
|
||||
(rx/map prepare)
|
||||
|
|
Loading…
Add table
Reference in a new issue