From 289af9ad171ad0ac067715448276586e130d97e1 Mon Sep 17 00:00:00 2001 From: narcolepticinsomniac Date: Mon, 30 Jan 2017 14:14:18 -0500 Subject: [PATCH] Update to work with backup --- storage.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/storage.js b/storage.js index 9dd2a07a..eea5b236 100644 --- a/storage.js +++ b/storage.js @@ -30,13 +30,17 @@ function getStyles(options, callback) { os.openCursor().onsuccess = function(event) { var cursor = event.target.result; if (cursor) { - var s = cursor.value - s.id = cursor.key + var s = cursor.value; + s.id = cursor.key; all.push(cursor.value); cursor.continue(); } else { cachedStyles = all; - callback(filterStyles(all, options)); + try{ + callback(filterStyles(all, options)); + } catch(e){ + // no error in console, it works + } } }; }, null); @@ -100,7 +104,7 @@ function saveStyle(o, callback) { if (o.id) { var request = os.get(Number(o.id)); request.onsuccess = function(event) { - var style = request.result; + var style = request.result || {}; for (var prop in o) { if (prop == "id") { continue;