Skip to content

fix(profile): 使时间表分割线等变更实时同步到课程表组件#1878

Merged
HelloWRC merged 3 commits into
ClassIsland:masterfrom
laoshuikaixue:fix/profile-timelayout-realtime-update
Jun 21, 2026
Merged

fix(profile): 使时间表分割线等变更实时同步到课程表组件#1878
HelloWRC merged 3 commits into
ClassIsland:masterfrom
laoshuikaixue:fix/profile-timelayout-realtime-update

Conversation

@laoshuikaixue

Copy link
Copy Markdown
Contributor

分割线(TimeType==2)增删修改后,ValidTimeLayoutItems 缓存未失效,主界面课程表组件保持旧渲染结果,需要重启才更新。

修复方式:

  • TimeLayout:订阅每个 TimeLayoutItem 的属性变化,属性变更时触发 LayoutObjectChanged 通知关联课表
  • ClassPlan:TimeLayoutOnLayoutItemChanged 末尾补充 NotifyClassesChanged(),使分割线等非上课时间点增删也令 ValidTimeLayoutItems 标脏并通知绑定

这个 Pull Request 做了什么?

档案编辑器中修改时间表(增删分割线、修改时间点属性等)后,主界面课程表组件无法实时更新,需重启应用才能生效。
根因在于 ClassPlan.ValidTimeLayoutItems 存在缓存,而分割线(TimeType == 2)及时间点属性变化不会触发 ClassesChanged,导致缓存未标脏,界面仍显示旧数据。
修复方案保持在模型层,无需在编辑器窗口额外手动刷新:

  • TimeLayout:监听每个 TimeLayoutItem 的属性变化,任何字段(StartTimeEndTimeTimeTypeBreakName 等)变动时,通过 LayoutObjectChanged 通知所有关联课表;
  • ClassPlan:在 TimeLayoutOnLayoutItemChanged 末尾补充 NotifyClassesChanged(),确保新增/删除分割线或非上课时间点时,ValidTimeLayoutItems 缓存失效。

该改动对所有使用 ValidTimeLayoutItems 的位置(课程表组件、明日课表、倒计时组件、通知提供方等)均生效,编辑器修改后即同步更新。

检查清单

  • 我已经在本地测试过这个 PR,确保欲实现的功能或修复的问题能正常工作。
2026-06-21.12-55-33.mp4

分割线(TimeType==2)增删修改后,ValidTimeLayoutItems 缓存未失效,主界面课程表组件保持旧渲染结果,需要重启才更新。

修复方式:
- TimeLayout:订阅每个 TimeLayoutItem 的属性变化,属性变更时触发 LayoutObjectChanged 通知关联课表
- ClassPlan:TimeLayoutOnLayoutItemChanged 末尾补充 NotifyClassesChanged(),使分割线等非上课时间点增删也令 ValidTimeLayoutItems 标脏并通知绑定
@laoshuikaixue laoshuikaixue requested review from a team and HelloWRC as code owners June 21, 2026 04:59
- 删除 ClassesChanged 事件定义后的空行
- 保持代码格式整洁一致

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9028e22b89

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ClassIsland.Shared/Models/Profile/TimeLayout.cs
- 在Replace操作中正确处理移除和插入的类信息
- 添加TimeLayoutItem属性变更事件监听以同步类索引
- 实现时间类型变更时的类索引映射和通知机制
- 为Move操作添加类列表刷新功能
- 优化时间布局项的属性变更处理逻辑
@HelloWRC HelloWRC merged commit f7f930e into ClassIsland:master Jun 21, 2026
2 checks passed
@HelloWRC

Copy link
Copy Markdown
Member

感谢您的贡献🤝

昔涟 爱

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.

2 participants