Skip to content

Commit 839e76b

Browse files
committed
fix: fix unable to update funded amount
1 parent 1b2cd44 commit 839e76b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/impact-reports.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,14 @@ export const updateFundedAmount = async (
302302
const release = await reportsMutex.acquire();
303303

304304
try {
305-
const reports = await getReports();
306-
const report = reports.find((r) => r.hypercertId === hypercertId);
307-
if (report) {
308-
report.fundedSoFar += amount;
309-
}
305+
const currentReports = await getReports();
306+
const updatedReports = currentReports.map(report =>
307+
report.hypercertId === hypercertId
308+
? { ...report, fundedSoFar: report.fundedSoFar + amount }
309+
: report
310+
);
311+
312+
reports = updatedReports;
310313
} finally {
311314
release();
312315
}

0 commit comments

Comments
 (0)