mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 00:01:51 -05:00
🐛 Fix behavior when an image upload fails
This commit is contained in:
parent
51a4232cf2
commit
47d347f357
2 changed files with 14 additions and 3 deletions
|
@ -27,6 +27,7 @@
|
||||||
(s/def ::message-position #{:fixed :floating :inline})
|
(s/def ::message-position #{:fixed :floating :inline})
|
||||||
(s/def ::message-status #{:visible :hide})
|
(s/def ::message-status #{:visible :hide})
|
||||||
(s/def ::message-controls #{:none :close :inline-actions :bottom-actions})
|
(s/def ::message-controls #{:none :close :inline-actions :bottom-actions})
|
||||||
|
(s/def ::message-tag string?)
|
||||||
(s/def ::label string?)
|
(s/def ::label string?)
|
||||||
(s/def ::callback fn?)
|
(s/def ::callback fn?)
|
||||||
(s/def ::message-action (s/keys :req-un [::label ::callback]))
|
(s/def ::message-action (s/keys :req-un [::label ::callback]))
|
||||||
|
@ -52,7 +53,7 @@
|
||||||
(ptk/reify ::hide
|
(ptk/reify ::hide
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(update state :message assoc :status :hide))
|
(d/update-when state :message assoc :status :hide))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
|
@ -61,6 +62,15 @@
|
||||||
(rx/delay +animation-timeout+)
|
(rx/delay +animation-timeout+)
|
||||||
(rx/take-until stoper))))))
|
(rx/take-until stoper))))))
|
||||||
|
|
||||||
|
(defn hide-tag
|
||||||
|
[tag]
|
||||||
|
(ptk/reify ::hide-tag
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ state stream]
|
||||||
|
(let [message (get state :message)]
|
||||||
|
(when (= (:tag message) tag)
|
||||||
|
(rx/of hide))))))
|
||||||
|
|
||||||
(defn error
|
(defn error
|
||||||
([content] (error content {}))
|
([content] (error content {}))
|
||||||
([content {:keys [timeout] :or {timeout 3000}}]
|
([content {:keys [timeout] :or {timeout 3000}}]
|
||||||
|
|
|
@ -394,7 +394,8 @@
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of (dm/show {:content (tr "media.loading")
|
(rx/of (dm/show {:content (tr "media.loading")
|
||||||
:type :info
|
:type :info
|
||||||
:timeout nil}))
|
:timeout nil
|
||||||
|
:tag :media-loading}))
|
||||||
(->> (if (string? uri)
|
(->> (if (string? uri)
|
||||||
(->> (rx/of uri)
|
(->> (rx/of uri)
|
||||||
(rx/map prepare-uri)
|
(rx/map prepare-uri)
|
||||||
|
@ -420,7 +421,7 @@
|
||||||
:else
|
:else
|
||||||
(rx/throw error))))
|
(rx/throw error))))
|
||||||
(rx/finalize (fn []
|
(rx/finalize (fn []
|
||||||
(st/emit! dm/hide)))))))))
|
(st/emit! (dm/hide-tag :media-loading))))))))))
|
||||||
|
|
||||||
|
|
||||||
;; --- Delete media object
|
;; --- Delete media object
|
||||||
|
|
Loading…
Add table
Reference in a new issue