fix: prevent progress bar regression & add debounce to PlayButton#153
Conversation
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
总体说明该PR在播放器控制组件中引入了防抖状态处理机制,防止短暂的UI闪烁,并改进了播放条拖拽后的位置同步逻辑,通过获取实际播放位置来确保状态一致性。 变更清单
审查工作量评估🎯 2 (Simple) | ⏱️ ~12 分钟 可能相关的PR
建议标签
兔兔之诗
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/features/player/components/PlayerSlider.tsx`:
- Around line 106-113: The current timeout handler calls Orpheus.getPosition()
but lacks error handling, which can leave isSeeking true and
seekTimeoutRef.current non-null if the promise rejects; update the timeout
callback to await or handle the promise with try/catch (or .then/.catch) and
ensure that regardless of success or failure you call isSeeking.set(false) and
set seekTimeoutRef.current = null, while on error optionally logging the error;
target the anonymous timeout callback that references Orpheus.getPosition(),
seekTimeoutRef, isSeeking, and position.
| seekTimeoutRef.current = setTimeout(() => { | ||
| isSeeking.set(false) | ||
| seekTimeoutRef.current = null | ||
| // 获取实际播放位置并同步,避免暂停状态下 position 未更新导致进度条回退 | ||
| void Orpheus.getPosition().then((actualPosition) => { | ||
| position.set(actualPosition) | ||
| isSeeking.set(false) | ||
| seekTimeoutRef.current = null | ||
| }) | ||
| }, 5000) |
There was a problem hiding this comment.
核心修复逻辑正确,建议添加错误处理
通过在清除 isSeeking 之前先获取实际播放位置并同步 position 值,有效解决了暂停状态下拖动进度条后回退的问题。
但是 Orpheus.getPosition() 是异步调用,如果失败可能导致 isSeeking 永远不会被清除,进度条会卡在 seek 位置。建议添加错误处理:
🔧 建议的错误处理
seekTimeoutRef.current = setTimeout(() => {
// 获取实际播放位置并同步,避免暂停状态下 position 未更新导致进度条回退
void Orpheus.getPosition().then((actualPosition) => {
position.set(actualPosition)
isSeeking.set(false)
seekTimeoutRef.current = null
+ }).catch(() => {
+ // 获取位置失败时,仍需清除 seeking 状态,使用当前 seekPosition 作为回退
+ isSeeking.set(false)
+ seekTimeoutRef.current = null
})
}, 5000)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| seekTimeoutRef.current = setTimeout(() => { | |
| isSeeking.set(false) | |
| seekTimeoutRef.current = null | |
| // 获取实际播放位置并同步,避免暂停状态下 position 未更新导致进度条回退 | |
| void Orpheus.getPosition().then((actualPosition) => { | |
| position.set(actualPosition) | |
| isSeeking.set(false) | |
| seekTimeoutRef.current = null | |
| }) | |
| }, 5000) | |
| seekTimeoutRef.current = setTimeout(() => { | |
| // 获取实际播放位置并同步,避免暂停状态下 position 未更新导致进度条回退 | |
| void Orpheus.getPosition().then((actualPosition) => { | |
| position.set(actualPosition) | |
| isSeeking.set(false) | |
| seekTimeoutRef.current = null | |
| }).catch(() => { | |
| // 获取位置失败时,仍需清除 seeking 状态,使用当前 seekPosition 作为回退 | |
| isSeeking.set(false) | |
| seekTimeoutRef.current = null | |
| }) | |
| }, 5000) |
🤖 Prompt for AI Agents
In `@src/features/player/components/PlayerSlider.tsx` around lines 106 - 113, The
current timeout handler calls Orpheus.getPosition() but lacks error handling,
which can leave isSeeking true and seekTimeoutRef.current non-null if the
promise rejects; update the timeout callback to await or handle the promise with
try/catch (or .then/.catch) and ensure that regardless of success or failure you
call isSeeking.set(false) and set seekTimeoutRef.current = null, while on error
optionally logging the error; target the anonymous timeout callback that
references Orpheus.getPosition(), seekTimeoutRef, isSeeking, and position.
|
谢谢你的贡献喵! |
Co-authored-by: roitium <roitium@users.noreply.github.com> Co-authored-by: Roitium. <65794453+roitium@users.noreply.github.com> Co-authored-by: longlin li <gnulonglin@gmail.com> fix: prevent progress bar regression & add debounce to PlayButton (#153) fix: improve error message for failed lyric providers (BBPLAYER-5Q) (#157) fix: update PlaySlide info after song's change (#159) fix: prevent re-playing when click same track. (#168)
修复两个小问题:
修复前:
2026-01-23.17.25.39.mp4
修复后:
2026-01-23.17.25.44.mp4
Summary by CodeRabbit
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.