mirror of
https://github.com/penpot/penpot.git
synced 2026-05-11 19:13:49 +00:00
* ✨ Implement asset re-uploading to wasm * ✨ Show toast instead of error screen when webgl context is lost * 🎉 Recover context after webgl context restored event * 🎉 Set Read-only mode when the context has been lost * ✨ Disable scroll & zoom when context loss * ✨ Fix stale reload payload * ✨ Use existing debounce util to take screenshots * ✨ Implement design / ux specs * ✨ Fix playwright test by looking for toast, not error page
45 lines
1.8 KiB
Clojure
45 lines
1.8 KiB
Clojure
(ns app.main.data.render-wasm
|
|
(:require
|
|
[beicon.v2.core :as rx]
|
|
[potok.v2.core :as ptk]))
|
|
|
|
(defn context-lost
|
|
[]
|
|
(ptk/reify ::context-lost
|
|
ptk/UpdateEvent
|
|
(update [_ state]
|
|
(let [already-lost? (get-in state [:render-state :lost])
|
|
prev-read-only? (get-in state [:workspace-global :read-only?])
|
|
prev-options-mode (get-in state [:workspace-global :options-mode])]
|
|
(-> state
|
|
(update :render-state
|
|
(fn [render-state]
|
|
(cond-> (assoc render-state :lost true)
|
|
(not already-lost?)
|
|
(assoc :pre-context-lost-read-only? prev-read-only?
|
|
:pre-context-lost-options-mode prev-options-mode))))
|
|
(assoc-in [:workspace-global :options-mode] :inspect)
|
|
(assoc-in [:workspace-global :read-only?] true))))
|
|
ptk/WatchEvent
|
|
(watch [_ _ _]
|
|
(rx/of :interrupt))))
|
|
|
|
(defn context-restored
|
|
[]
|
|
(ptk/reify ::context-restored
|
|
ptk/UpdateEvent
|
|
(update [_ state]
|
|
(let [restored-read-only? (get-in state [:render-state :pre-context-lost-read-only?]
|
|
(get-in state [:workspace-global :read-only?]))
|
|
restored-options-mode (get-in state [:render-state :pre-context-lost-options-mode]
|
|
(get-in state [:workspace-global :options-mode]))]
|
|
(-> state
|
|
(update :render-state #(dissoc % :lost
|
|
:pre-context-lost-read-only?
|
|
:pre-context-lost-options-mode))
|
|
(assoc-in [:workspace-global :options-mode] restored-options-mode)
|
|
(assoc-in [:workspace-global :read-only?] restored-read-only?))))
|
|
ptk/WatchEvent
|
|
(watch [_ _ _]
|
|
(rx/of :interrupt))))
|