@rocketsearch/vue-uappi 0.2.2 → 0.2.3
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/runtime/rocket.js +7 -3
package/package.json
CHANGED
package/runtime/rocket.js
CHANGED
|
@@ -358,10 +358,13 @@ export function createRocket (config) {
|
|
|
358
358
|
const opts = options || {};
|
|
359
359
|
const customKey = pageType === 'custom' ? landingKey(opts.customKey) : undefined;
|
|
360
360
|
if (!pageType || (pageType === 'custom' && !customKey)) return Promise.resolve([]);
|
|
361
|
-
|
|
361
|
+
// Banner por categoria (ROC-827): a API só devolve o segmentado se casar a categoria visitada,
|
|
362
|
+
// então ela entra no cache — senão a próxima categoria reaproveitaria o banner da anterior.
|
|
363
|
+
const categoryId = pageType === 'category' && page.categoryId ? page.categoryId : undefined;
|
|
364
|
+
const key = pageType + '|' + (opts.position || '') + '|' + (customKey || '') + '|' + (categoryId || '');
|
|
362
365
|
const hit = bannerCache[key];
|
|
363
366
|
if (hit && Date.now() - hit.at < BANNER_TTL) return hit.list;
|
|
364
|
-
const list = fetchBanners(pageType, opts.position, customKey).then((banners) => {
|
|
367
|
+
const list = fetchBanners(pageType, opts.position, customKey, categoryId).then((banners) => {
|
|
365
368
|
if (banners) return banners;
|
|
366
369
|
delete bannerCache[key];
|
|
367
370
|
return [];
|
|
@@ -371,11 +374,12 @@ export function createRocket (config) {
|
|
|
371
374
|
};
|
|
372
375
|
|
|
373
376
|
// null = falhou (não entra no cache).
|
|
374
|
-
async function fetchBanners (pageType, position, customKey) {
|
|
377
|
+
async function fetchBanners (pageType, position, customKey, categoryId) {
|
|
375
378
|
try {
|
|
376
379
|
const sessionId = await getSessionIdWithTimeout();
|
|
377
380
|
const params = { storeId: config.storeId, pageType, sessionId, position };
|
|
378
381
|
if (pageType === 'custom') params.customKey = customKey;
|
|
382
|
+
if (categoryId) params.categoryId = categoryId;
|
|
379
383
|
const res = await fetch(config.apiUrl + '/banners/context?' + query(params), { headers: headers() });
|
|
380
384
|
if (!res.ok) return null;
|
|
381
385
|
const banners = await res.json();
|