From d37a2766db5317230fe5b1b1509fb8f320ead07f Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 30 Apr 2020 12:25:55 +0200 Subject: [PATCH] :lipstick: Cosmetic fixes on storage ns. --- frontend/src/uxbox/util/storage.cljs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/src/uxbox/util/storage.cljs b/frontend/src/uxbox/util/storage.cljs index adfbe76a5..851068af4 100644 --- a/frontend/src/uxbox/util/storage.cljs +++ b/frontend/src/uxbox/util/storage.cljs @@ -7,18 +7,21 @@ (ns uxbox.util.storage (:require [uxbox.util.transit :as t])) +(defn- ^boolean is-worker? + [] + (or (= *target* "nodejs") + (not (exists? js/window)))) + (defn- persist [alias value] - (when-not (or (= *target* "nodejs") - (not (exists? js/window))) + (when-not (is-worker?) (let [key (name alias) value (t/encode value)] (.setItem js/localStorage key value)))) (defn- load [alias] - (when-not (or (= *target* "nodejs") - (not (exists? js/window))) + (when-not (is-worker?) (let [data (.getItem js/localStorage (name alias))] (try (t/decode data)