Skip to content

Commit

Permalink
fix infinite loop when schedule moved before weekend
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd committed Jan 19, 2025
1 parent 9d63b23 commit d39dd17
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/loot-core/src/client/data-hooks/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,19 @@ export function usePreviewTransactions(): UsePreviewTransactionsResult {

const dates: string[] = [];
let day = d.startOfDay(parseDate(schedule.next_date));
let i = 0;
if (isRecurring) {
while (day <= upcomingPeriodEnd) {
while (day <= upcomingPeriodEnd && i < 400) {
i++;
const nextDate = getNextDate(dateConditions, day);

if (parseDate(nextDate) > upcomingPeriodEnd) break;

if (dates.includes(nextDate)) {
day = parseDate(addDays(day, 1));
continue;
}

dates.push(nextDate);
day = parseDate(addDays(nextDate, 1));
}
Expand Down

0 comments on commit d39dd17

Please sign in to comment.