From 95650e4c1759939be7ae117523985b0013d10058 Mon Sep 17 00:00:00 2001 From: Krikorios <99836218+Krikorios@users.noreply.github.com> Date: Sun, 19 Apr 2026 00:08:56 +0300 Subject: [PATCH] perf: paginate docs list, lazy thumbnails, static cache headers --- templates/duplicates.html | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/templates/duplicates.html b/templates/duplicates.html index 7b28540..a428615 100644 --- a/templates/duplicates.html +++ b/templates/duplicates.html @@ -193,16 +193,28 @@ async function scanDuplicates(btn) { } async function deleteDoc(docId, btn) { - if (!confirm('حذف هذه الوثيقة نهائياً؟')) return; + if (!window.confirm('حذف هذه الوثيقة نهائياً؟')) return; + const original = btn.textContent; btn.disabled = true; - const res = await fetch(`/documents/${docId}`, { method: 'DELETE' }); - if (res.ok) { - // Reload so keeper-promotion (if the keeper was deleted) is reflected. - location.reload(); - } else { - alert('فشل الحذف.'); - btn.disabled = false; + btn.textContent = '...'; + try { + const res = await fetch(`/documents/${docId}`, { + method: 'DELETE', + headers: { 'Accept': 'application/json' }, + }); + 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) {