🎉 Add previous screen action

This commit is contained in:
Andrés Moya 2021-09-24 16:52:22 +02:00 committed by Alonso Torres
parent ed380c86eb
commit 4697a1904a
4 changed files with 30 additions and 0 deletions

View file

@ -132,6 +132,22 @@
(js/window.open (str uri) name)))))
(defn nav-back
[]
(ptk/reify ::nav-back
ptk/EffectEvent
(effect [_ _ _]
(ts/asap #(.back (.-history js/window))))))
(defn nav-back-local
"Navigate back only if the previous page is in penpot app."
[]
(let [location (.-location js/document)
referrer (u/uri (.-referrer js/document))]
(when (or (nil? (:host referrer))
(= (.-hostname location) (:host referrer)))
(nav-back))))
;; --- History API
(defn initialize-history