// };
//})(backupName);
- //var deleteFuncHandler = (function(backupName, elem) {
- // return function(event) {
- /*if (!confirm("Delete backup '" + backupName + "'?")) {
- return;
- }*/
-
- // bootbox.confirm("Delete backup '" + backupName + "'?", function(confirmed) {
- // if (confirmed) {
- // chrome.extension.getBackgroundPage().deleteBackup(backupName, function() {
-
- // });
-
- //if (elem.parentNode) {
- // elem.parentNode.removeChild(elem);
- //
- // removeBackupItemDiv (backupName);
- // }
- // });
-
-
- // };
- //})(backupName, elem);
-
if (insertAtBeginning && backupsDiv.childNodes.length > 0) {
// some items already exist
var firstNode = backupsDiv.childNodes[0];
return;
}
- deleteBackup (backupsList[i], loopFunc);
+ deleteBackup(backupsList[i]).then(loopFunc);
i++;
};
loopFunc ();
}
-
- //for (var i = 0; i < numItemsToDelete; i++) {
- // TODO WARNING: I'm calling deleteBackup rapidly, while deleting is async...(I should wait for each delete to complete before deleting the next)
- //deleteBackup (backupsList[i], function() {
-
- //});
- //}
-
});
}
chrome.action.setIcon({path: icon});
}
-function deleteBackup (backupName, callback) {
+async function deleteBackup(backupName) {
console.log("Deleting backup " + backupName);
- chrome.storage.local.remove(backupName, function() {
- //console.log ("=> Deleted backup " + backupName);
-
- chrome.storage.local.get("backups_list", function(items) {
- //console.log ("==> got backups_list " + backupName);
-
- if(!items.backups_list) {
- callback();
- return;
- }
-
- var backupsList = items.backups_list;
-
- var index = backupsList.indexOf(backupName);
- if (index >= 0) {
- backupsList.splice(index, 1);
- }
+ await chrome.storage.local.remove(backupName);
+ //console.log("=> Deleted backup " + backupName);
- //console.log ("===> Updating backups_list (removing " + backupName + ")");
+ const items = await chrome.storage.local.get("backups_list");
+ //console.log("==> got backups_list " + backupName);
- chrome.storage.local.set({"backups_list": backupsList}, function() {
- //console.log ("===> Updated backups_list (removed " + backupName + ")");
-
- callback();
- });
-
- //console.log ("==> EXIT got backups_list " + backupName);
- });
+ if (!items.backups_list) {
+ return;
+ }
- //console.log ("=> EXIT Deleted backup " + backupName);
- });
+ var backupsList = items.backups_list;
- //console.log("EXIT Deleting backup " + backupName);
+ var index = backupsList.indexOf(backupName);
+ if (index >= 0) {
+ backupsList.splice(index, 1);
+ }
+ //console.log("===> Updating backups_list (removing " + backupName + ")");
+ await chrome.storage.local.set({"backups_list": backupsList});
+ //console.log("===> Updated backups_list (removed " + backupName + ")");
}
function restoreNow(backupName) {
break;
case 'deleteBackup':
- deleteBackup(...request.args, sendResponse);
+ deleteBackup(...request.args).then(sendResponse);
asyncResponse = true;
break;