Merge pull request #2356 from rahulshukla-webkul/development
Development
This commit is contained in:
commit
abc7548cd2
|
|
@ -73,10 +73,6 @@
|
||||||
var slugs = JSON.parse(storedRecentlyViewed);
|
var slugs = JSON.parse(storedRecentlyViewed);
|
||||||
var updatedSlugs = {};
|
var updatedSlugs = {};
|
||||||
|
|
||||||
if (slugs.length > 3) {
|
|
||||||
slugs = slugs.slice(Math.max(slugs.length - 3, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
slugs = slugs.reverse();
|
slugs = slugs.reverse();
|
||||||
|
|
||||||
slugs.forEach(slug => {
|
slugs.forEach(slug => {
|
||||||
|
|
|
||||||
|
|
@ -178,10 +178,22 @@
|
||||||
if (existingViewed.indexOf(currentProductId) == -1) {
|
if (existingViewed.indexOf(currentProductId) == -1) {
|
||||||
existingViewed.push(currentProductId);
|
existingViewed.push(currentProductId);
|
||||||
|
|
||||||
if (existingViewed.length > 4)
|
if (existingViewed.length > 3)
|
||||||
existingViewed = existingViewed.slice(Math.max(existingViewed.length - 4, 1));
|
existingViewed = existingViewed.slice(Math.max(existingViewed.length - 4, 1));
|
||||||
|
|
||||||
window.localStorage.setItem('recentlyViewed', JSON.stringify(existingViewed));
|
window.localStorage.setItem('recentlyViewed', JSON.stringify(existingViewed));
|
||||||
|
} else {
|
||||||
|
var uniqueNames = [];
|
||||||
|
|
||||||
|
$.each(existingViewed, function(i, el){
|
||||||
|
if ($.inArray(el, uniqueNames) === -1) uniqueNames.push(el);
|
||||||
|
});
|
||||||
|
|
||||||
|
uniqueNames.push(currentProductId);
|
||||||
|
|
||||||
|
uniqueNames.splice(uniqueNames.indexOf(currentProductId), 1);
|
||||||
|
|
||||||
|
window.localStorage.setItem('recentlyViewed', JSON.stringify(uniqueNames));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue