Skip to content

fix: reset duration when updating notices - #409

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/reset-updated-duration
Open

fix: reset duration when updating notices#409
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/reset-updated-duration

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • restart a notice auto-close timer when the same key is updated
  • reuse the existing times update counter without resuming a paused notice
  • add a regression test that verifies the updated notice receives its full duration

Problem

Notifications.open increments times when an existing key is updated, but Notification did not pass that value to its timer. When a one-second notice was updated after 800 ms with the same one-second duration, it still closed about 200 ms later instead of remaining visible for another full second.

Validation

  • vitest run --maxWorkers=1 (3 files, 53 tests)
  • tsc --noEmit
  • father build (ESM, CJS, declarations)
  • Prettier and git diff --check
  • ESLint on the changed source files

I also checked the current open issues and PRs. The timer-related open PRs cover maximum timeout clamping, hover resume behavior, page blur, or progress styling; none resets the same-key update timer.

Summary by CodeRabbit

  • 新功能

    • 通知支持配置重复次数,提供更灵活的自动关闭控制。
    • 更新相同标识的通知时,自动关闭计时器会重新开始。
  • 错误修复

    • 修复通知内容更新后计时未正确重置的问题。
  • 测试

    • 新增通知更新及计时器重置场景的测试覆盖。

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: aae68bcc-87bc-4980-abad-692b7aef0080

📥 Commits

Reviewing files that changed from the base of the PR and between 3283f82 and 881a0f9.

📒 Files selected for processing (3)
  • src/Notification.tsx
  • src/hooks/useNoticeTimer.ts
  • tests/index.test.tsx

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

Notificationtimes 传递给 useNoticeTimer。计时器在相同 key 的通知更新时重置计时状态。新增测试验证更新后的通知按新的持续时间关闭。

Changes

通知计时器重置

Layer / File(s) Summary
计时器参数与组件接入
src/Notification.tsx, src/hooks/useNoticeTimer.ts
Notification 解构可选的 times 属性,并将其传递给更新后的 useNoticeTimer
通知更新时重启计时
src/hooks/useNoticeTimer.ts, tests/index.test.tsx
相同 key 的通知更新时,计时器重置经过时间和动画帧时间,并将进度更新为 0。测试验证更新后的通知在新的持续时间结束后移除。

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 881a0

The change restarts a notification's auto-close duration when the same notice is updated while preserving paused behavior. Its impact is limited to local notification timing, and no actionable merge-blocking risk remains beyond normal checks and review.

Poem

小兔传入 times,计时轻轻响,
相同 key 更新,旧钟重新上。
进度归于零,通知内容亮,
时间走完后,安静收场。
新测试蹦蹦跳,结果很清爽。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:更新已有通知时重置持续时间。标题简洁、明确,并与代码修改和回归测试一致。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.21%. Comparing base (3283f82) to head (881a0f9).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #409      +/-   ##
==========================================
+ Coverage   99.20%   99.21%   +0.01%     
==========================================
  Files          12       12              
  Lines         376      383       +7     
  Branches      102      103       +1     
==========================================
+ Hits          373      380       +7     
  Misses          3        3              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant