Fix permanent delete

This commit is contained in:
2025-05-27 11:43:10 +02:00
parent e5d54c499b
commit a67470d616
11 changed files with 176 additions and 126 deletions

View File

@@ -32,6 +32,13 @@ window.emptyTrash = function() {
fetch('/api/rooms/trash')
.then(r => r.json())
.then(files => {
if (!files || !files.length) {
// No files to delete, just close the modal
const modal = bootstrap.Modal.getInstance(document.getElementById('emptyTrashModal'));
modal.hide();
return Promise.resolve([]);
}
// Get unique room IDs
const roomIds = [...new Set(files.map(file => file.room_id))];
@@ -61,12 +68,20 @@ window.emptyTrash = function() {
// Close the modal
const modal = bootstrap.Modal.getInstance(document.getElementById('emptyTrashModal'));
modal.hide();
// Refresh the view to ensure everything is up to date
fetchFiles();
} else {
console.error('Failed to empty trash in some rooms');
// Show error message to user
const grid = document.getElementById('fileGrid');
grid.innerHTML = '<div class="col"><div class="text-danger">Failed to empty trash. Please try again.</div></div>';
}
})
.catch(error => {
console.error('Error emptying trash:', error);
// Show error message to user
const grid = document.getElementById('fileGrid');
grid.innerHTML = '<div class="col"><div class="text-danger">Error emptying trash. Please try again.</div></div>';
});
};