fix(comments): keep expanded list after show/hide moderation#960
Merged
imaegoo merged 1 commit intoMay 28, 2026
Merged
Conversation
Spam/top toggles on a comment emitted `load`, which re-ran `initComments` and replaced the in-memory list with the first page only. Update the moderated comment locally instead of reloading all comments. Fixes #527 Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
审阅者指南(在小型 PR 上折叠)审阅者指南更新 TkComment 的审核行为,使其修改现有的评论对象,而不是触发 reload 事件,从而避免在执行审核操作后整个评论列表被重新初始化并折叠。 更新后的 TkComment 审核行为流程图flowchart LR
A[管理员使用行内审核控件] --> B[TkComment 接收审核结果集]
B --> C["Object.assign(comment, set) 更新现有评论"]
C --> D[UI 就地反映更新后的评论]
D --> E[评论列表保持在当前页并维持展开状态]
B -.-> F[不会触发 load 事件]
F -.-> G[评论列表不会被重新初始化]
文件级改动
与关联问题的对照评估
提示与命令与 Sourcery 交互
自定义你的体验访问你的 控制面板 以:
获取帮助Original review guide in EnglishReviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates TkComment moderation behavior to mutate the existing comment object instead of emitting a reload event, preventing the entire comment list from being reinitialized and collapsed after moderation actions. Flow diagram for updated TkComment moderation behaviorflowchart LR
A[Admin uses inline moderation control] --> B[TkComment receives moderation result set]
B --> C["Object.assign(comment, set) updates existing comment"]
C --> D[UI reflects updated comment in place]
D --> E[Comment list stays on current page and remains expanded]
B -.-> F[No load event emitted]
F -.-> G[Comment list is not reinitialized]
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - 我在这里给出了一些高层次的反馈:
- 直接使用
Object.assign修改this.comment(一个 prop)会破坏 Vue 的单向数据流;建议通过触发更新事件或使用 store/action,让父组件拥有并更新 comment 的状态。 - 移除
load事件的触发后,任何依赖该事件的父级监听器或后续逻辑现在都会被跳过;请确认是否仍然应该触发一个更有针对性的事件(例如moderated或updated),以便在就地修改之外继续保持父组件的状态同步。
给 AI Agent 的提示词
Please address the comments from this code review:
## Overall Comments
- Directly mutating `this.comment` (a prop) with `Object.assign` can break Vue’s one-way data flow; consider emitting an update event or using a store/action so the parent owns and updates the comment state.
- By removing the `load` event emission, any parent listeners or follow-up logic tied to that event are now skipped; verify whether a more targeted event (e.g., `moderated` or `updated`) should still be emitted to keep the parent in sync beyond just the in-place mutation.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- Directly mutating
this.comment(a prop) withObject.assigncan break Vue’s one-way data flow; consider emitting an update event or using a store/action so the parent owns and updates the comment state. - By removing the
loadevent emission, any parent listeners or follow-up logic tied to that event are now skipped; verify whether a more targeted event (e.g.,moderatedorupdated) should still be emitted to keep the parent in sync beyond just the in-place mutation.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Directly mutating `this.comment` (a prop) with `Object.assign` can break Vue’s one-way data flow; consider emitting an update event or using a store/action so the parent owns and updates the comment state.
- By removing the `load` event emission, any parent listeners or follow-up logic tied to that event are now skipped; verify whether a more targeted event (e.g., `moderated` or `updated`) should still be emitted to keep the parent in sync beyond just the in-place mutation.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When an admin shows/hides or tops/untops a comment from the public comment list, update that comment in place instead of reloading the entire comment list.
Problem
Fixes #527. Moderation actions emitted
load, which triggeredinitCommentsand reset the list to the first page, collapsing comments the user had already expanded.Test plan
Summary by Sourcery
Bug Fixes:
Original summary in English
Summary by Sourcery
Bug Fixes: