From a18caa4dbb15ef1d7e81a2464b68651cc9526085 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 7 Oct 2022 23:17:49 +0545 Subject: [PATCH] bg: check local storage directly on startup See if we have any backups, and if not, create one right away. This is more robust than checking localStorage.lastBackupTime directly as that isn't used anywhere else. Plus, MV3 won't support it. --- background.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/background.js b/background.js index 94884ec..0c90a71 100644 --- a/background.js +++ b/background.js @@ -8,8 +8,11 @@ if (!localStorage.prefsBackupTimer) { localStorage.prefsBackupTimer = "30"; } -if (!localStorage.lastBackupTime) { - localStorage.lastBackupTime = -1; +// Create a backup on first install (or if storage is wiped for some reason). +chrome.storage.local.get("backups_list", function(items) { + if (items.backups_list) { + return; + } // Create a backup now var d = new Date(); @@ -18,7 +21,7 @@ if (!localStorage.lastBackupTime) { backupNow(true, formattedDate, function(success, backupName, backupObj) { // backup completed }); -} +}); function initAlarm () { //console.log("initAlarm"); -- 2.39.2