MCPcopy Index your code
hub / github.com/easydiffusion/easydiffusion / deleteKeys

Function deleteKeys

ui/media/js/utils.js:1074–1098  ·  view source on GitHub ↗
(keyToDelete)

Source from the content-addressed store, hash-verified

1072
1073// USE WITH CARE - THIS MAY DELETE ALL ENTRIES
1074async function deleteKeys(keyToDelete) {
1075 let confirmationMessage = keyToDelete
1076 ? `This will delete the template with key "${keyToDelete}". Continue?`
1077 : "This will delete ALL templates. Continue?";
1078 if (confirm(confirmationMessage)) {
1079 return openDB().then(db => {
1080 let tx = db.transaction("EasyDiffusionSettings", "readwrite");
1081 let store = tx.objectStore("EasyDiffusionSettings");
1082 return new Promise((resolve, reject) => {
1083 store.openCursor().onsuccess = function (event) {
1084 let cursor = event.target.result;
1085 if (cursor) {
1086 if (!keyToDelete || cursor.key === keyToDelete) {
1087 cursor.delete();
1088 }
1089 cursor.continue();
1090 } else {
1091 // refresh the dropdown and resolve
1092 resolve();
1093 }
1094 };
1095 });
1096 });
1097 }
1098}
1099
1100/**
1101 * @param {String} Data URL of the image

Callers

nothing calls this directly

Calls 3

confirmFunction · 0.85
openDBFunction · 0.85
deleteMethod · 0.80

Tested by

no test coverage detected