Merge pull request #2356 from rahulshukla-webkul/development

Development
This commit is contained in:
Jitendra Singh 2020-02-07 11:11:28 +05:30 committed by GitHub
commit abc7548cd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -73,10 +73,6 @@
var slugs = JSON.parse(storedRecentlyViewed);
var updatedSlugs = {};
if (slugs.length > 3) {
slugs = slugs.slice(Math.max(slugs.length - 3, 1));
}
slugs = slugs.reverse();
slugs.forEach(slug => {

View File

@ -178,10 +178,22 @@
if (existingViewed.indexOf(currentProductId) == -1) {
existingViewed.push(currentProductId);
if (existingViewed.length > 4)
if (existingViewed.length > 3)
existingViewed = existingViewed.slice(Math.max(existingViewed.length - 4, 1));
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));
}
},