🎉 Basic changes to use penpot as a library

This commit is contained in:
Pablo Alba 2022-10-03 11:39:58 +02:00 committed by Alejandro Alonso
parent 10e0cf121b
commit 369dc8ffb5
11 changed files with 96 additions and 43 deletions

View file

@ -6,6 +6,7 @@
(ns app.util.storage
(:require
[app.common.exceptions :as ex]
[app.common.transit :as t]
[app.util.globals :as g]
[app.util.timers :as tm]))
@ -38,7 +39,8 @@
{}
(range len)))))
(defonce storage (atom (load (unchecked-get g/global "localStorage"))))
;; Using ex/ignoring because can receive a DOMException like this when importing the code as a library:
;; Failed to read the 'localStorage' property from 'Window': Storage is disabled inside 'data:' URLs.
(defonce storage (atom (load (ex/ignoring (unchecked-get g/global "localStorage")))))
(add-watch storage :persistence #(persist js/localStorage %3 %4))