Skip to content

Commit

Permalink
improve data loading performace
Browse files Browse the repository at this point in the history
  • Loading branch information
imkarimkarim committed Sep 10, 2022
1 parent 11e3e55 commit c754d6f
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/App/Pages/Car/Car.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,18 @@ function SaleSection({ products, car }) {
sumSaleCommission = Math.floor(fullSum * (car.commission * 0.01));
}

useEffect(() => {
if (salesInfos && salesInfos.length !== products.length) {
getOneProductCalcs(products[salesInfos.length].customeId);
}
}, [salesInfos]);

useEffect(() => {
if (init.current) {
init.current = false;
for (let i = 0; i < products.length; i++) {
(function (ind) {
setTimeout(function () {
getOneProductCalcs(products[ind].customeId);
}, 100 + 500 * ind);
})(i);
}
getOneProductCalcs(products[0].customeId);
}

// waht if
// اولیو توی ایف بالا بگیره و بقیه رو تو ریپلای
// ipcRenderer.on...

ipcRenderer.on("oneProductCalcs", (event, product) => {
if (!salesInfos || salesInfos.length === 0) {
setsalesInfos([product]);
Expand Down

0 comments on commit c754d6f

Please sign in to comment.