diff --git a/js/admin.js b/js/admin.js
index e75eccf..5257b56 100644
--- a/js/admin.js
+++ b/js/admin.js
@@ -447,39 +447,33 @@ function handleVideothequeUpload(input) {
try {
// ✅ Lots de 1 seul pour éviter le blocage Blu-ray.com
- for (let i = 0; i < items.length; i += 1) {
- const batch = items.slice(i, i + 1);
+ const batchSize = 5; // ou 10 selon la puissance du serveur
+ for (let i = 0; i < items.length; i += batchSize) {
+ const batch = items.slice(i, i + batchSize);
const res = await fetch(`${API_URL}?action=import_batch`, {
method: 'POST',
headers: { 'Authorization': localStorage.getItem('token'), 'Content-Type': 'application/json' },
body: JSON.stringify({ type: 'videotheque', items: batch })
});
-
- if (!res.ok) throw new Error(`Erreur HTTP ${res.status}`);
- const data = await res.json();
- if (!data.success) throw new Error(data.error || "Échec API");
-
- totalImp += data.imported || 0;
- totalSkp += data.skipped || 0;
- processed += batch.length;
- updateImportModal(processed, items.length);
- await new Promise(r => setTimeout(r, 500)); // Délai de sécurité
+ // ... traitement de la réponse
+ // Petit délai optionnel (100 ms) pour éviter de saturer le serveur
+ await new Promise(r => setTimeout(r, 100));
+ }
+
+ input.value = '';
+ closeImportModal();
+ const msg = totalSkp > 0 ? ` (${totalSkp} ignoré(s))` : '';
+ showSuccessModal(`${totalImp} édition(s) importée(s).${msg}`);
+ loadDashboardData();
+ } catch (err) {
+ console.error(err);
+ closeImportModal();
+ alert("❌ Échec import : " + err.message);
+ input.value = '';
+ }
+ };
+ reader.readAsText(file);
}
-
- input.value = '';
- closeImportModal();
- const msg = totalSkp > 0 ? ` (${totalSkp} ignoré(s))` : '';
- showSuccessModal(`${totalImp} édition(s) importée(s).${msg}`);
- loadDashboardData();
- } catch (err) {
- console.error(err);
- closeImportModal();
- alert("❌ Échec import : " + err.message);
- input.value = '';
- }
- };
- reader.readAsText(file);
-}
function showImportModal(total, type) {
document.getElementById('import-modal-title').innerHTML = type === 'critique' ? ' Import Critiques' : ' Import Vidéothèque';