perf: paginate docs list, lazy thumbnails, static cache headers

This commit is contained in:
Krikorios
2026-04-19 00:08:56 +03:00
parent da900cab2d
commit 95650e4c17
+20 -8
View File
@@ -193,16 +193,28 @@ async function scanDuplicates(btn) {
} }
async function deleteDoc(docId, btn) { async function deleteDoc(docId, btn) {
if (!confirm('حذف هذه الوثيقة نهائياً؟')) return; if (!window.confirm('حذف هذه الوثيقة نهائياً؟')) return;
const original = btn.textContent;
btn.disabled = true; btn.disabled = true;
const res = await fetch(`/documents/${docId}`, { method: 'DELETE' }); btn.textContent = '...';
if (res.ok) { try {
// Reload so keeper-promotion (if the keeper was deleted) is reflected. const res = await fetch(`/documents/${docId}`, {
location.reload(); method: 'DELETE',
} else { headers: { 'Accept': 'application/json' },
alert('فشل الحذف.'); });
btn.disabled = false; if (res.ok) {
// Reload so keeper-promotion (if the keeper was deleted) is reflected.
location.reload();
return;
}
let msg = `HTTP ${res.status}`;
try { const j = await res.json(); if (j.error) msg += `${j.error}`; } catch (_) {}
alert(`فشل الحذف: ${msg}`);
} catch (e) {
alert(`خطأ في الشبكة: ${e.message}`);
} }
btn.disabled = false;
btn.textContent = original;
} }
async function unflagDuplicate(docId, btn) { async function unflagDuplicate(docId, btn) {