nodebb-plugin-ezoic-infinite 1.4.17 → 1.4.18
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.
- package/package.json +1 -1
- package/public/client.js +22 -9
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
// Survit aux navigations ajaxify (contrairement à state.definedIds remis à zéro dans cleanup).
|
|
19
19
|
// Nécessaire pour savoir si on doit appeler destroyPlaceholders avant recyclage.
|
|
20
20
|
const sessionDefinedIds = new Set();
|
|
21
|
+
|
|
22
|
+
// IDs actuellement en cours d'insertion (lock pour éviter les doublons de race condition)
|
|
23
|
+
const insertingIds = new Set();
|
|
21
24
|
|
|
22
25
|
const state = {
|
|
23
26
|
pageKey: null,
|
|
@@ -221,17 +224,27 @@
|
|
|
221
224
|
function insertAfter(target, id, kindClass, afterPos) {
|
|
222
225
|
if (!target || !target.insertAdjacentElement) return null;
|
|
223
226
|
if (findWrap(kindClass, afterPos)) return null;
|
|
224
|
-
|
|
225
|
-
//
|
|
227
|
+
|
|
228
|
+
// CRITICAL: Double-lock pour éviter race conditions sur les doublons
|
|
229
|
+
// 1. Vérifier qu'aucun autre thread n'est en train d'insérer cet ID
|
|
230
|
+
if (insertingIds.has(id)) return null;
|
|
231
|
+
|
|
232
|
+
// 2. Vérifier qu'aucun placeholder avec cet ID n'existe déjà dans le DOM
|
|
226
233
|
const existingPh = document.getElementById(`${PLACEHOLDER_PREFIX}${id}`);
|
|
227
|
-
if (existingPh && existingPh.isConnected)
|
|
228
|
-
|
|
229
|
-
|
|
234
|
+
if (existingPh && existingPh.isConnected) return null;
|
|
235
|
+
|
|
236
|
+
// Acquérir le lock
|
|
237
|
+
insertingIds.add(id);
|
|
238
|
+
|
|
239
|
+
try {
|
|
240
|
+
const wrap = buildWrap(id, kindClass, afterPos);
|
|
241
|
+
target.insertAdjacentElement('afterend', wrap);
|
|
242
|
+
attachFillObserver(wrap, id);
|
|
243
|
+
return wrap;
|
|
244
|
+
} finally {
|
|
245
|
+
// Libérer le lock après 100ms (le temps que le DOM soit stable)
|
|
246
|
+
setTimeout(() => insertingIds.delete(id), 100);
|
|
230
247
|
}
|
|
231
|
-
const wrap = buildWrap(id, kindClass, afterPos);
|
|
232
|
-
target.insertAdjacentElement('afterend', wrap);
|
|
233
|
-
attachFillObserver(wrap, id);
|
|
234
|
-
return wrap;
|
|
235
248
|
}
|
|
236
249
|
|
|
237
250
|
function destroyUsedPlaceholders() {
|