Refactor the current streak logic to validate streaks at the end of each day instead of updating immediately when habits are completed.
Goal:
Prevent accidental streak resets and ensure streak logic runs only once per day.
Problem:
Currently, streak updates are triggered during habit completion or modification. This can cause incorrect streak resets if the function runs multiple times (e.g., when deleting habits after completing them).
Solution:
Implement a daily streak validation system that:
- Runs when the app is opened
- Checks yesterday’s completion status
- Updates streak only once per day
- Prevents duplicate updates using lastStreakDate guard
Refactor the current streak logic to validate streaks at the end of each day instead of updating immediately when habits are completed.
Goal:
Prevent accidental streak resets and ensure streak logic runs only once per day.
Problem:
Currently, streak updates are triggered during habit completion or modification. This can cause incorrect streak resets if the function runs multiple times (e.g., when deleting habits after completing them).
Solution:
Implement a daily streak validation system that: