feat: highlight specific item in multipage playlist#150
Conversation
|
Caution Review failedThe pull request is closed. Walkthrough为远程播放列表多页面添加每项自定义渲染(FlashingTrackListItem)、列表引用(listRef)以启用程序化滚动,并基于 URL 查询参数 Changes
Sequence DiagramsequenceDiagram
participant Page as Multipage Page
participant TL as TrackList (FlashList)
participant FTLI as FlashingTrackListItem
participant Item as TrackListItem
Page->>TL: 传入 props (listRef, renderCustomItem)
TL->>TL: 初始化 FlashList 并绑定 ref
Page->>Page: 读取 URL cid
Note right of Page: 等待 tracksData 加载
Page->>TL: tracksData 就绪后(带 cid)
Page->>TL: 使用 listRef.scrollToIndex(cid 对应索引)
TL->>TL: 渲染列表项,调用 renderCustomItem 每项
TL->>FTLI: renderCustomItem 返回 FTLI 包装的项
FTLI->>FTLI: 根据 ExtraData.shouldFlash 启动 reanimated 动画
FTLI->>Item: 渲染内部 TrackListItem 并处理交互(toggle/menu/select)
Item->>Page: 交互事件(播放、菜单、进入/退出选择)触发回调
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly Related PRs
Poem
🚥 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 |
SafeDep Report SummaryNo dependency changes detected. Nothing to scan. This report is generated by SafeDep Github App |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/app/playlist/remote/multipage/`[bvid].tsx:
- Around line 122-136: The useEffect that delays calling
listRef.current?.scrollToIndex via setTimeout can leak timers or run after
unmount; capture the timer ID when calling setTimeout inside the effect (where
cid, tracksData, index, listRef and scrollToIndex are used) and return a cleanup
function that calls clearTimeout on that ID so the pending callback is cancelled
when cid/tracksData change or the component unmounts.
🧹 Nitpick comments (2)
src/features/playlist/remote/components/FlashingTrackListItem.tsx (1)
26-31: 在useAnimatedStyle中访问theme可能导致问题
useAnimatedStyle的回调在 UI 线程上执行,但theme.colors.primaryContainer是一个普通的 JS 对象值。当theme发生变化时,动画样式可能不会正确更新。建议将
backgroundColor移到静态样式中,或使用useAnimatedProps配合 shared value:♻️ 建议的修复方案
export function FlashingTrackListItem({ shouldFlash, ...props }: FlashingTrackListItemProps) { const theme = useTheme() const opacity = useSharedValue(0) const animatedStyle = useAnimatedStyle(() => { return { - backgroundColor: theme.colors.primaryContainer, opacity: opacity.value, } }) + const overlayStyle = useMemo( + () => ({ + backgroundColor: theme.colors.primaryContainer, + }), + [theme.colors.primaryContainer], + ) // ... return ( <Animated.View style={[styles.container]}> <TrackListItem {...props} /> <Animated.View pointerEvents='none' - style={[StyleSheet.absoluteFill, animatedStyle]} + style={[StyleSheet.absoluteFill, overlayStyle, animatedStyle]} /> </Animated.View> ) }src/app/playlist/remote/multipage/[bvid].tsx (1)
138-191:renderCustomItem与renderItemDefault存在大量重复代码此回调函数与
RemoteTrackList.tsx中的renderItemDefault几乎完全相同,唯一区别是使用了FlashingTrackListItem和shouldFlash属性。考虑将通用逻辑抽取为共享函数或高阶组件,减少维护成本。例如,可以让
renderItemDefault接受一个可选的ItemComponent参数。
Summary by CodeRabbit
发版说明
✏️ Tip: You can customize this high-level summary in your review settings.