bep40 commited on
Commit
e1f964c
·
1 Parent(s): b1c20ef

fix: lazyloading main SP list when Thêm SP exist — topAdded branch passes full pool

Browse files
Files changed (1) hide show
  1. src/vaix-rag.js +8 -4
src/vaix-rag.js CHANGED
@@ -2073,14 +2073,18 @@ function renderDiversePanel(count) {
2073
  // (load() merges products_url_added into allProducts and prepends them).
2074
  // Skip any base product whose sku/slug/link already appears in topAdded so
2075
  // the same "Thêm SP" product never renders twice (duplicate cards).
2076
- let room = n;
 
 
 
2077
  const out = [];
2078
- for (let i = 0; i < topAdded.length && room > 0; i++) { out.push(topAdded[i]); room--; }
2079
- for (let i = 0; i < base.length && room > 0; i++) {
 
2080
  const b = base[i];
2081
  const k = String((b.sku || b.model || '') + '|' + (b.link || '')).toUpperCase();
2082
  if (seenTop.has(k)) continue;
2083
- out.push(b); room--;
2084
  }
2085
  renderPanelResults(out);
2086
  return;
 
2073
  // (load() merges products_url_added into allProducts and prepends them).
2074
  // Skip any base product whose sku/slug/link already appears in topAdded so
2075
  // the same "Thêm SP" product never renders twice (duplicate cards).
2076
+ // LAZY-LOAD FIX: when fullPool (panel open, n>=20) we pass the ENTIRE
2077
+ // deduped list (max 6k, then full) so renderPanelResults' lazy pagination
2078
+ // engages (first 24 + "▼ Xem mai multo" + scroll). Previously this branch
2079
+ // capped at n=20 and lazy loading NEVER appeared on the main SP list.
2080
  const out = [];
2081
+ for (let i = 0; i < topAdded.length; i++) { out.push(topAdded[i]); }
2082
+ let _room = fullPool ? Math.max(n, 6000) : n;
2083
+ for (let i = 0; i < base.length && _room > 0; i++) {
2084
  const b = base[i];
2085
  const k = String((b.sku || b.model || '') + '|' + (b.link || '')).toUpperCase();
2086
  if (seenTop.has(k)) continue;
2087
+ out.push(b); _room--;
2088
  }
2089
  renderPanelResults(out);
2090
  return;