Repository navigation
fix: avoid closing notice when duration changes to non-positive - #421
Conversation
|
@mokshupadhyay is attempting to deploy a commit to the afc163's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. Walkthrough此变更调整通知时长变化时的计时器重置和进度更新条件,并新增测试,验证非正时长不会触发关闭,以及时长恢复为正数后重新计时。 Changes通知计时器
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #421 +/- ##
=======================================
Coverage 99.21% 99.21%
=======================================
Files 12 12
Lines 382 383 +1
Branches 103 103
=======================================
+ Hits 379 380 +1
Misses 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
When a notice that is already showing is updated with
duration: 0(orfalse/null) to make it persistent, it was still closed.useNoticeTimerreacts to a duration change by resetting its state and callingsetWalking(durationMs > 0), butsetWalkingonly takes effect on the next render. In that renderwalkingis stilltrue, so the timer effect runs with a non-positive duration and firesonClose.Two small changes in
src/hooks/useNoticeTimer.ts:durationMs <= 0, so it never starts for a persistent notice;lastRafTimeRef, so going from0back to a positive duration starts a fresh timer instead of reusing a stale timestamp.Before / after (new tests):
duration: 1, updated toduration: 0, 5 s passonClosecalled 1 time1then0,falseornull, 2 s passonClosecalled1→0→1Tests:
vitest runpasses (6 files, 65 tests); 5 of the new tests fail on the original source.eslint src/reports 0 errors (5 warnings, same on the base branch);tsc --noEmitprints no errors. I did not run the docs examples.Open PR #409 also edits
useNoticeTimer.ts(restarting the timer on same-key updates); it is a different symptom, but it touches nearby lines, so I'm happy to rebase on whichever lands first.Summary by CodeRabbit
0、false或null后,通知不会因计时而自动关闭,更新后的内容仍会显示。