bep40 commited on
Commit
86ebc5a
·
verified ·
1 Parent(s): 7b4c475

Fix modal order: zalo-sync (dataset) products on top, manual vai-add-product after

Browse files
Files changed (1) hide show
  1. src/vaix-rag.js +7 -2
src/vaix-rag.js CHANGED
@@ -2130,14 +2130,19 @@ function renderDiversePanel(count) {
2130
  const added = (window.vaixPromo && typeof window.vaixPromo.getAddedProducts === 'function') ? window.vaixPromo.getAddedProducts() : [];
2131
  // Also surface products added via URL/OCR (kept in products_url_added.json, already
2132
  // merged into allProducts by load()). Their home is _addedBy === 'products_url_added'.
2133
- const addedByUrl = allProducts.filter(function (p) { return p && p._addedBy === 'products_url_added'; });
2134
  const base = allProducts;
2135
  // Merge + dedup by sku so a product only appears once at the top.
2136
  const topAdded = [];
2137
  const seenTop = new Set();
2138
  const pushTop = function (p) { if (!p) return; const k = String((p.sku || p.model || '') + '|' + (p.link || '')).toUpperCase(); if (!seenTop.has(k)) { seenTop.add(k); topAdded.push(p); } };
2139
- added.forEach(pushTop);
 
 
 
 
2140
  addedByUrl.forEach(pushTop);
 
2141
  if (topAdded.length) {
2142
  // The base list (allProducts) ALREADY contains productEdits/url_added rows
2143
  // (load() merges products_url_added into allProducts and prepends them).
 
2130
  const added = (window.vaixPromo && typeof window.vaixPromo.getAddedProducts === 'function') ? window.vaixPromo.getAddedProducts() : [];
2131
  // Also surface products added via URL/OCR (kept in products_url_added.json, already
2132
  // merged into allProducts by load()). Their home is _addedBy === 'products_url_added'.
2133
+ const addedByUrl = allProducts.filter(function (p) { return p && (p._addedBy === 'products_url_added' || p._addedBy === 'zalo-products-all-autosync'); });
2134
  const base = allProducts;
2135
  // Merge + dedup by sku so a product only appears once at the top.
2136
  const topAdded = [];
2137
  const seenTop = new Set();
2138
  const pushTop = function (p) { if (!p) return; const k = String((p.sku || p.model || '') + '|' + (p.link || '')).toUpperCase(); if (!seenTop.has(k)) { seenTop.add(k); topAdded.push(p); } };
2139
+ // ORDER: Zalo-sync rows (from bep40/zalo-products-all) must ALWAYS surface
2140
+ // on TOP of the modal list — they are the newest dataset products. Manual
2141
+ // "Thêm SP"/vai-add-product rows come after them. (Previously manual rows
2142
+ // were pushed first, so a manually-added product like Toshiba 283212 sat
2143
+ // above newer sync products.)
2144
  addedByUrl.forEach(pushTop);
2145
+ added.forEach(pushTop);
2146
  if (topAdded.length) {
2147
  // The base list (allProducts) ALREADY contains productEdits/url_added rows
2148
  // (load() merges products_url_added into allProducts and prepends them).