0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 07:50:43 -05:00

🐛 Force sync update on storage before immediate refresh

This commit is contained in:
Andrey Antukh 2024-10-10 14:41:15 +02:00 committed by Alonso Torres
parent b0bfb8006d
commit 87dfd2b3c8

View file

@ -10,6 +10,7 @@
[app.common.transit :as t]
[app.util.functions :as fns]
[app.util.globals :as g]
[app.util.time :as dt]
[cuerdas.core :as str]
[okulary.util :as ou]))
@ -157,3 +158,11 @@
(defonce user (create-storage local-storage-backend "penpot-user"))
(defonce storage (create-storage local-storage-backend "penpot"))
(defonce session (create-storage session-storage-backend "penpot"))
(defonce before-unload
(letfn [(on-before-unload [_]
(binding [*sync* true]
(swap! global assoc ::last-refresh (dt/now))
(swap! user assoc ::last-refresh (dt/now))))]
(.addEventListener g/window "beforeunload" on-before-unload)
on-before-unload))