aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEv Bogue <ev@evbogue.com>2019-04-04 09:57:51 -0500
committerEv Bogue <ev@evbogue.com>2019-04-04 09:57:51 -0500
commitfd2a344391c940c41cb7065928e74e872dcd2e3c (patch)
treea4976fe75120f90deb98f9f76889b8dacde4ad4d
parent0b284168f623235f293fd43e03e50e1ba8f2dd86 (diff)
fix bug where log did not update when it did not exist
-rw-r--r--app.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/app.js b/app.js
index 668f4b2..5ad1547 100644
--- a/app.js
+++ b/app.js
@@ -143,7 +143,13 @@ function route () {
// contact new items from the log onto the client's log of everything
var num = serverData.log.length - clientLog.log.length
var diff = serverData.log.slice(0, num)
- var oldLog = JSON.parse(localStorage['log'])
+
+ if (localStorage['log']) {
+ var oldLog = JSON.parse(localStorage['log'])
+ } else {
+ var oldLog = []
+ }
+
var newLog = diff.concat(oldLog)
localStorage['log'] = JSON.stringify(newLog)