From 50b94d6870d32856d08c6a044563c9a65b8a6cdc Mon Sep 17 00:00:00 2001 From: Marco H Date: Fri, 11 Feb 2022 13:16:59 +0100 Subject: [PATCH] Update boot.js Fixes Uncaught Error: Expecting a string, got undefined see https://github.com/espruino/BangleApps/issues/1423 --- apps/sleeplog/boot.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/sleeplog/boot.js b/apps/sleeplog/boot.js index 7ec71742c..883e497a5 100644 --- a/apps/sleeplog/boot.js +++ b/apps/sleeplog/boot.js @@ -90,7 +90,10 @@ if (global.sleeplog.enabled) { var storage = require("Storage"); // read previous logfile - var log = JSON.parse(atob(storage.read(this.logfile))); + var logContent = storage.read(this.logfile) || ""; + + // parse previous logfile + var log = JSON.parse(logContent.length > 0 ? atob(logContent) : "[]") ; // remove last state if it was unknown and is less then 10min ago if (log.length > 0 && log[0][1] === 0 &&