]> git.wh0rd.org Git - chrome-ext/tabs-backup.git/commitdiff
bg: check local storage directly on startup
authorMike Frysinger <vapier@gentoo.org>
Fri, 7 Oct 2022 17:32:49 +0000 (23:17 +0545)
committerMike Frysinger <vapier@gentoo.org>
Fri, 7 Oct 2022 17:32:49 +0000 (23:17 +0545)
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

index 94884ecd267b4e10cfaa42a4636f286e4f4ca863..0c90a71179e59a7816e7305ef353e0adbcca9c86 100644 (file)
@@ -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");