nodebb-plugin-ezoic-infinite 1.4.18 → 1.4.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/client.js +28 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-ezoic-infinite",
3
- "version": "1.4.18",
3
+ "version": "1.4.20",
4
4
  "description": "Production-ready Ezoic infinite ads integration for NodeBB 4.x",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/public/client.js CHANGED
@@ -402,6 +402,14 @@
402
402
 
403
403
 
404
404
  function refillUnfilled() {
405
+ // Si tous les IDs disponibles sont blacklistés, ne pas réessayer
406
+ const totalPoolSize = state.poolTopics.length + state.poolPosts.length + state.poolCategories.length +
407
+ state.usedTopics.size + state.usedPosts.size + state.usedCategories.size;
408
+ if (totalPoolSize > 0 && state.badIds.size >= totalPoolSize) {
409
+ // Tous les IDs disponibles sont blacklistés - arrêter les retry
410
+ return;
411
+ }
412
+
405
413
  const wraps = Array.from(document.querySelectorAll(`.${WRAP_CLASS}`));
406
414
  let scheduledAny = false;
407
415
 
@@ -421,8 +429,18 @@
421
429
  continue;
422
430
  }
423
431
 
432
+ // Skip si déjà blacklisté
433
+ if (state.badIds && state.badIds.has(id)) {
434
+ state.retryById.delete(id);
435
+ continue;
436
+ }
437
+
424
438
  const tries = (state.retryById.get(id) || 0);
425
- if (tries >= 8) { state.badIds && state.badIds.add(id); continue; }
439
+ if (tries >= 3) {
440
+ state.badIds && state.badIds.add(id);
441
+ state.retryById.delete(id);
442
+ continue;
443
+ }
426
444
 
427
445
  const r = safeRect(wrap);
428
446
  if (r && (r.top > window.innerHeight + 1200 || r.bottom < -1200)) continue;
@@ -432,7 +450,14 @@
432
450
  scheduledAny = true;
433
451
  }
434
452
 
435
- if (scheduledAny) scheduleRefill(700);
453
+ // Ne re-scheduler que si au moins un ID a été enqueued ET qu'il reste des IDs non-blacklistés
454
+ if (scheduledAny) {
455
+ const totalPoolSize = state.poolTopics.length + state.poolPosts.length + state.poolCategories.length +
456
+ state.usedTopics.size + state.usedPosts.size + state.usedCategories.size;
457
+ if (totalPoolSize === 0 || state.badIds.size < totalPoolSize) {
458
+ scheduleRefill(700);
459
+ }
460
+ }
436
461
  }
437
462
 
438
463
  function callShowAdsWhenReady(id) {
@@ -799,7 +824,7 @@
799
824
  // Réinitialiser le compteur d'attente de recyclage à chaque reprise de scroll
800
825
  state.poolWaitAttempts = 0;
801
826
  enforceNoAdjacentAds();
802
- scheduleRefill(200);
827
+ scheduleRefill(2000);
803
828
  // Tenter aussi d'insérer de nouvelles pubs si de nouveaux items sont apparus
804
829
  scheduleRun();
805
830
  });