Skip to content

fix(TimeLayoutItem):修复了在时间表中点击刷新按钮时,若时间表中存在两个起始时间相同的项就会发生顺序跳变的问题(issue#1820)#1839

Merged
HelloWRC merged 1 commit into
ClassIsland:masterfrom
wan-an-zz:fix-issue#1820
Jun 11, 2026

Conversation

@wan-an-zz

Copy link
Copy Markdown
Contributor

这个 Pull Request 做了什么?

问题复现

编辑档案 -> 时间表 -> 添加一个开始时间和结束时间相同的项(如分割线) -> 再添加一个开始时间和刚刚添加的那个相同的项 -> 反复点击“刷新”按钮 -> 每次点击“刷新”按钮,这两个项的顺序都会发生变化

问题溯源

当“刷新”按钮被点击时,调用了ClassIsland.Views.ProfileSettingsWindow.UpdateTimeLayout()方法,该方法内会对TimeLayout.Layouts集合进行排序,由于该集合内部的元素实现了IComparable接口,排序时会调用CompareTo()方法对集合内部的各项元素进行比较,但是该方法只比较了每个TimeLayoutItemStartTime(开始时间)而没有比较EndTime(结束时间),导致在排序时两个开始时间相同的项会在点击“刷新”按钮后发生顺序跳变

修复

CompareTo()方法内加入对EndTime的比较

相关 Issue

Fixes #1820

检查清单

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

@wan-an-zz wan-an-zz requested review from a team and HelloWRC as code owners June 7, 2026 13:01

@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: 73cf66f8e2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

return -1;
}

if (o.EndTime > EndTime)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve order for exactly equal time points

When two zero-duration items share the same timestamp, such as a separator and an action, this new tie-breaker still falls through to return 0 because both StartTime and EndTime match. UpdateTimeLayout() uses List.Sort() followed by Reverse(), and List.Sort() is not stable for items that compare equal, so refreshing can still reorder those valid same-time entries; the fix needs a deterministic final tie-breaker or a stable sort that preserves original order.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

实际使用场景中不太可能同时设定两个开始时间和结束时间相同的项。

@DryIce-cc DryIce-cc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这个修复是有效的

@HelloWRC HelloWRC merged commit 39a25d6 into ClassIsland:master Jun 11, 2026
1 of 2 checks passed
@HelloWRC

Copy link
Copy Markdown
Member

感谢您的贡献🤝

昔涟 爱

@all-contributors please add @wan-an-zz for code

@allcontributors

Copy link
Copy Markdown
Contributor

@HelloWRC

I've put up a pull request to add @wan-an-zz! 🎉

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.

分割线的优先级低导致课程之前的分割线显示在课程之后

3 participants