Repository navigation
Conversation
…te default parseInt(duration) || 30 treated 0 as falsy, so a 0-minute session in an imported backup became 30 minutes, inflating study hours, the productivity score and the Century Club achievement. Only fall back to the 30-minute default when the value is not a number; zero and negative values clamp to the 1-minute minimum like any other out-of-range input.
…port date filter Upstream 344b1fc made importJSON drop activities whose date is not a valid ISO date, so the four dateless activities in this fixture were all filtered out on the merge commit and CI saw [] instead of [1, 30, 1, 30]. The duration expectations are unchanged.
|
The earlier red CI run came from the merge with Merged current |
…-zero # Conflicts: # CHANGELOG.md
|
Conflicts with |
🌌 Pull Request Summary
Fixes #10
Problem
When a backup JSON is imported,
importJSONcleaned durations withMath.max(1, parseInt(a.duration, 10) || 30). Because0is falsy, a 0-minute session silently became 30 minutes, inflating logged hours, the productivity score and the Century Club achievement, while-10correctly clamped to1.Root cause
The
|| 30fallback fires for any falsy parsed value, not just missing or non-numeric ones.parseInt("0", 10)is0, so a valid0was replaced by the 30-minute default instead of being clamped to the 1-minute minimum like other out-of-range values.Fix
Fall back to
30only when the parsed value isNaN(missing or non-numeric); otherwise clamp withMath.max(1, …)as before:Imported durations now behave exactly as specified in the issue:
-10 → 1,0 → 1,'abc'/missing →30.Type of Change
How Has This Been Tested?
Extended the existing
clamps progress to 0–100 and keeps durations positivetest intests/storage.test.jsto assert the exact values from the issue's table (-10 → 1,0 → 1,'x' → 30, missing →30). The new assertions failed against the old code (0 became 30) and pass with the fix.npm test: 52/52 pass in 4 timezonesnpm run lint: cleannpm run format:check: clean(The change is in import sanitization only, verified through the unit tests; no UI behavior outside the documented table is affected.)
Contributor Checklist
escapeHTML()to prevent XSS. (n/a — no user-facing HTML changed)CHANGELOG.md)npm run checkpasses locally.docs/DECISIONS.mdanddocs/FLOW.mdneed no updates.