mirror of
https://github.com/penpot/penpot.git
synced 2025-07-30 18:38:22 +02: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" : {
|
"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" : {
|
"translations" : {
|
||||||
"en" : "The image format is not supported (must be svg, jpg or png)."
|
"en" : "The image format is not supported (must be svg, jpg or png)."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"errors.image-too-large" : {
|
"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" : {
|
"translations" : {
|
||||||
"en" : "The image is too large to be inserted (must be under 5mb)."
|
"en" : "The image is too large to be inserted (must be under 5mb)."
|
||||||
}
|
}
|
||||||
|
@ -585,7 +585,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"errors.unexpected-error" : {
|
"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" : {
|
"translations" : {
|
||||||
"en" : "An unexpected error occurred.",
|
"en" : "An unexpected error occurred.",
|
||||||
"fr" : "Une erreur inattendue c'est produite"
|
"fr" : "Une erreur inattendue c'est produite"
|
||||||
|
@ -625,6 +625,12 @@
|
||||||
},
|
},
|
||||||
"unused" : true
|
"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" : {
|
"image.new" : {
|
||||||
"translations" : {
|
"translations" : {
|
||||||
"en" : "New image",
|
"en" : "New image",
|
||||||
|
|
|
@ -375,11 +375,13 @@
|
||||||
(throw (ex-info (tr "errors.image-format-unsupported") {})))
|
(throw (ex-info (tr "errors.image-format-unsupported") {})))
|
||||||
file)
|
file)
|
||||||
|
|
||||||
on-success on-uploaded
|
on-success #(do (st/emit! dm/hide)
|
||||||
|
(on-uploaded %))
|
||||||
|
|
||||||
on-error #(if (.-message %)
|
on-error #(do (st/emit! dm/hide)
|
||||||
(rx/of (dm/error (.-message %)))
|
(if (.-message %)
|
||||||
(rx/of (dm/error (tr "errors.unexpected-error"))))
|
(rx/of (dm/error (.-message %)))
|
||||||
|
(rx/of (dm/error (tr "errors.unexpected-error")))))
|
||||||
|
|
||||||
prepare
|
prepare
|
||||||
(fn [file]
|
(fn [file]
|
||||||
|
@ -387,6 +389,10 @@
|
||||||
:library-id library-id
|
:library-id library-id
|
||||||
:content file})]
|
:content file})]
|
||||||
|
|
||||||
|
(st/emit! (dm/show {:content (tr "image.loading")
|
||||||
|
:type :info
|
||||||
|
:timeout nil}))
|
||||||
|
|
||||||
(->> (rx/from files)
|
(->> (rx/from files)
|
||||||
(rx/map check-file)
|
(rx/map check-file)
|
||||||
(rx/map prepare)
|
(rx/map prepare)
|
||||||
|
|
|
@ -305,13 +305,11 @@
|
||||||
([file on-uploaded]
|
([file on-uploaded]
|
||||||
(us/verify fn? on-uploaded)
|
(us/verify fn? on-uploaded)
|
||||||
(ptk/reify ::upload-image
|
(ptk/reify ::upload-image
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
(assoc-in state [:workspace-local :uploading] true))
|
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [check-file
|
(let [file-id (get-in state [:workspace-page :file-id])
|
||||||
|
|
||||||
|
check-file
|
||||||
(fn [file]
|
(fn [file]
|
||||||
(when (> (.-size file) max-file-size)
|
(when (> (.-size file) max-file-size)
|
||||||
(throw (ex-info (tr "errors.image-too-large") {})))
|
(throw (ex-info (tr "errors.image-too-large") {})))
|
||||||
|
@ -319,14 +317,10 @@
|
||||||
(throw (ex-info (tr "errors.image-format-unsupported") {})))
|
(throw (ex-info (tr "errors.image-format-unsupported") {})))
|
||||||
file)
|
file)
|
||||||
|
|
||||||
finalize-upload #(assoc-in % [:workspace-local :uploading] false)
|
on-success #(do (st/emit! dm/hide)
|
||||||
|
|
||||||
file-id (get-in state [:workspace-page :file-id])
|
|
||||||
|
|
||||||
on-success #(do (st/emit! finalize-upload)
|
|
||||||
(on-uploaded %))
|
(on-uploaded %))
|
||||||
|
|
||||||
on-error #(do (st/emit! finalize-upload)
|
on-error #(do (st/emit! dm/hide)
|
||||||
(if (.-message %)
|
(if (.-message %)
|
||||||
(rx/of (dm/error (.-message %)))
|
(rx/of (dm/error (.-message %)))
|
||||||
(rx/of (dm/error (tr "errors.unexpected-error")))))
|
(rx/of (dm/error (tr "errors.unexpected-error")))))
|
||||||
|
@ -337,6 +331,9 @@
|
||||||
:file-id file-id
|
:file-id file-id
|
||||||
:content file})]
|
:content file})]
|
||||||
|
|
||||||
|
(st/emit! (dm/show {:content (tr "image.loading")
|
||||||
|
:type :info
|
||||||
|
:timeout nil}))
|
||||||
(->> (rx/of file)
|
(->> (rx/of file)
|
||||||
(rx/map check-file)
|
(rx/map check-file)
|
||||||
(rx/map prepare)
|
(rx/map prepare)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue