Skip to content

Commit 5f34833

Browse files
committed
fixes
1 parent 76ed734 commit 5f34833

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

components/trustpilot/sources/new-service-reviews/new-service-reviews.mjs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ export default {
5858
// Use the shared method from the app directly
5959
let result = await this.trustpilot.fetchServiceReviews(fetchParams);
6060

61-
while (result.length === 100) {
62-
fetchParams.page += 1;
63-
result = result.concat(await this.trustpilot.fetchServiceReviews(fetchParams));
61+
while (result.reviews && result.reviews.length === 100) {
62+
fetchParams.page = (fetchParams.page || 1) + 1;
63+
const nextResult = await this.trustpilot.fetchServiceReviews(fetchParams);
64+
result.reviews = result.reviews.concat(nextResult.reviews || []);
6465
}
6566

6667
const reviews = result.reviews || [];
@@ -71,15 +72,14 @@ export default {
7172
}
7273

7374
// Emit reviews (already parsed by the action)
74-
let latestReviewTime = lastReviewTime;
75+
let latestReviewTime = lastReviewTime;
7576

76-
for (const review of reviews) {
77-
// Track the latest review time
78-
const reviewTime = new Date(review.createdAt).toISOString();
79-
if (!latestReviewTime || new Date(reviewTime) > new Date(latestReviewTime)) {
80-
latestReviewTime = reviewTime;
81-
}
82-
}
77+
for (const review of reviews) {
78+
// Track the latest review time
79+
const reviewTime = new Date(review.createdAt).toISOString();
80+
if (!latestReviewTime || new Date(reviewTime) > new Date(latestReviewTime)) {
81+
latestReviewTime = reviewTime;
82+
}
8383

8484
// Emit the review with unique ID and summary
8585
this.$emit(review, {

0 commit comments

Comments
 (0)