修复 EdgeOne Pages 平台评论删除与点赞状态显示异常#997
Conversation
审阅者指南(在小型 PR 上折叠)审阅者指南使 EdgeOne Pages 的评论 DTO 与标准实现保持一致,以确保删除和点赞/点踩状态正常工作,并为特定的 EdgeOne 构件调整 ESLint 忽略路径。 EdgeOne Pages COMMENT_GET 更新后的评论 DTO 时序图sequenceDiagram
actor User
participant Frontend
participant COMMENT_GET
participant toCommentDto
User->>Frontend: request comments
Frontend->>COMMENT_GET: COMMENT_GET
COMMENT_GET->>toCommentDto: toCommentDto(comment, uid, replies, comments, cfg)
toCommentDto-->>COMMENT_GET: dto { liked, disliked, ups, downs, isOwner, like }
COMMENT_GET-->>Frontend: response with updated dto
Frontend-->>User: render delete button, like/dislike count and state based on dto
文件级变更
提示和命令与 Sourcery 交互
自定义你的使用体验访问你的 控制面板 以:
获取帮助Original review guide in EnglishReviewer's guide (collapsed on small PRs)Reviewer's GuideAligns EdgeOne Pages comment DTO with the standard implementation so that deletion and like/dislike state work correctly, and adjusts ESLint ignore paths for specific EdgeOne artifacts. Sequence diagram for EdgeOne Pages COMMENT_GET updated comment DTOsequenceDiagram
actor User
participant Frontend
participant COMMENT_GET
participant toCommentDto
User->>Frontend: request comments
Frontend->>COMMENT_GET: COMMENT_GET
COMMENT_GET->>toCommentDto: toCommentDto(comment, uid, replies, comments, cfg)
toCommentDto-->>COMMENT_GET: dto { liked, disliked, ups, downs, isOwner, like }
COMMENT_GET-->>Frontend: response with updated dto
Frontend-->>User: render delete button, like/dislike count and state based on dto
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我在这里给出一些整体性的反馈:
- 在
toCommentDto中,like仍然是从comment.like.length派生出来的,而liked/ups则是从comment.ups派生的。如果这些数组将来出现不一致,可能会导致点赞数不一致;建议让它们基于同一个数据源,或者明确文档化它们在使用上的差异。 - 由于
ups/downs只用于计算数量和成员关系,你可以将它们内联(例如:ups: (comment.ups || []).length),从而避免额外变量,并让 DTO 转换更简洁。
给 AI Agent 的提示
Please address the comments from this code review:
## Overall Comments
- In `toCommentDto`, `like` is still derived from `comment.like.length` while `liked`/`ups` are derived from `comment.ups`, which could lead to inconsistent like counts if those arrays ever diverge; consider basing both on the same source or explicitly documenting the difference in usage.
- Since `ups`/`downs` are only used to compute counts and membership, you could inline them (e.g., `ups: (comment.ups || []).length`) to avoid extra variables and keep the DTO transformation more compact.帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续的代码评审。
Original comment in English
Hey - I've left some high level feedback:
- In
toCommentDto,likeis still derived fromcomment.like.lengthwhileliked/upsare derived fromcomment.ups, which could lead to inconsistent like counts if those arrays ever diverge; consider basing both on the same source or explicitly documenting the difference in usage. - Since
ups/downsare only used to compute counts and membership, you could inline them (e.g.,ups: (comment.ups || []).length) to avoid extra variables and keep the DTO transformation more compact.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `toCommentDto`, `like` is still derived from `comment.like.length` while `liked`/`ups` are derived from `comment.ups`, which could lead to inconsistent like counts if those arrays ever diverge; consider basing both on the same source or explicitly documenting the difference in usage.
- Since `ups`/`downs` are only used to compute counts and membership, you could inline them (e.g., `ups: (comment.ups || []).length`) to avoid extra variables and keep the DTO transformation more compact.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Thanks. I kept the legacy I also kept the local |
修复 EdgeOne Pages 平台评论删除与点赞状态显示异常
EdgeOne Pages 的
toCommentDto返回字段与标准实现不一致,缺少isOwner、ups、downs、disliked字段。这会导致:
实际后端逻辑中,
COMMENT_DELETE_FOR_USER和COMMENT_LIKE均能正常工作;问题仅出在COMMENT_GET返回的 DTO 字段不完整。本次修复:
isOwner字段,用于前端判断是否显示用户删除按钮;ups/downs字段,用于前端显示点赞 / 点踩计数;disliked字段,用于前端恢复点踩状态;liked改为基于ups.includes(uid)判断;like字段以保持兼容。Summary by Sourcery
使 EdgeOne Pages 评论 DTO 与标准字段保持一致,以修复删除和点赞/点踩状态显示问题。
Bug 修复:
isOwner标志,以便前端能够正确显示用户自己评论的删除按钮。ups/downs计数和disliked状态,使点赞/点踩的数量和状态在刷新后能够正确保持。增强:
like计数以确保向后兼容的同时,将liked/disliked标志基于ups/downs数组。Original summary in English
Summary by Sourcery
Align EdgeOne Pages comment DTO with standard fields to fix deletion and like/dislike state display issues.
Bug Fixes:
Enhancements: