mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-24 22:12:17 -03:00
Add button to clear all saved canvas states
Introduces a 'Clear Cache' button to the Canvas widget UI, allowing users to clear all saved canvas states. Implements the clearAllCanvasStates function in db.js to handle the deletion of all canvas state entries from the database.
This commit is contained in:
20
js/db.js
20
js/db.js
@@ -94,4 +94,24 @@ export async function removeCanvasState(id) {
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export async function clearAllCanvasStates() {
|
||||
console.log("DB: Clearing all canvas states...");
|
||||
const db = await openDB();
|
||||
return new Promise((resolve, reject) => {
|
||||
const transaction = db.transaction([STORE_NAME], 'readwrite');
|
||||
const store = transaction.objectStore(STORE_NAME);
|
||||
const request = store.clear();
|
||||
|
||||
request.onerror = (event) => {
|
||||
console.error("DB: Error clearing canvas states:", event.target.error);
|
||||
reject("Error clearing states.");
|
||||
};
|
||||
|
||||
request.onsuccess = () => {
|
||||
console.log("DB: All canvas states cleared successfully.");
|
||||
resolve();
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user