Skip to content

Commit

Permalink
Merge pull request #30 from Yashi002/#1x69mn1
Browse files Browse the repository at this point in the history
Improve payload preparation for search products(#1x69mn1)
  • Loading branch information
adityasharma7 authored Jan 7, 2022
2 parents d5d141d + 1b9676c commit dc96db5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changelogs/unreleased/-1x69mn1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Improve payload preparation for search products
ticket_id: "#1x69mn1"
merge_request: 30
author: Yashi Verma
type: changed
3 changes: 2 additions & 1 deletion src/store/modules/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ const actions: ActionTree<ProductState, RootState> = {
async fetchProducts ( { commit, state }, { productIds }) {
const cachedProductIds = Object.keys(state.cached);
const productIdFilter= productIds.reduce((filter: string, productId: any) => {
if (filter !== '') filter += ' OR '
// If product already exist in cached products skip
if (cachedProductIds.includes(productId)) {
return filter;
} else {
// checking condition that if the filter is not empty then adding 'OR' to the filter
if (filter !== '') filter += ' OR '
return filter += productId;
}
}, '');
Expand Down

0 comments on commit dc96db5

Please sign in to comment.