0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-12 07:41:43 -05:00

🐛 Fix behavior when an image upload fails

This commit is contained in:
Andrés Moya 2020-09-25 11:38:57 +02:00 committed by Andrey Antukh
parent 51a4232cf2
commit 47d347f357
2 changed files with 14 additions and 3 deletions

View file

@ -27,6 +27,7 @@
(s/def ::message-position #{:fixed :floating :inline})
(s/def ::message-status #{:visible :hide})
(s/def ::message-controls #{:none :close :inline-actions :bottom-actions})
(s/def ::message-tag string?)
(s/def ::label string?)
(s/def ::callback fn?)
(s/def ::message-action (s/keys :req-un [::label ::callback]))
@ -52,7 +53,7 @@
(ptk/reify ::hide
ptk/UpdateEvent
(update [_ state]
(update state :message assoc :status :hide))
(d/update-when state :message assoc :status :hide))
ptk/WatchEvent
(watch [_ state stream]
@ -61,6 +62,15 @@
(rx/delay +animation-timeout+)
(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
([content] (error content {}))
([content {:keys [timeout] :or {timeout 3000}}]

View file

@ -394,7 +394,8 @@
(rx/concat
(rx/of (dm/show {:content (tr "media.loading")
:type :info
:timeout nil}))
:timeout nil
:tag :media-loading}))
(->> (if (string? uri)
(->> (rx/of uri)
(rx/map prepare-uri)
@ -420,7 +421,7 @@
:else
(rx/throw error))))
(rx/finalize (fn []
(st/emit! dm/hide)))))))))
(st/emit! (dm/hide-tag :media-loading))))))))))
;; --- Delete media object