Skip to content

fix: remove category check from resetViewState#654

Merged
wjyrich merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-335941
Sep 29, 2025
Merged

fix: remove category check from resetViewState#654
wjyrich merged 1 commit into
linuxdeepin:masterfrom
wjyrich:fix-bug-335941

Conversation

@wjyrich

@wjyrich wjyrich commented Sep 29, 2025

Copy link
Copy Markdown
Contributor
  1. Removed conditional check for FreeCategory in AppList.qml's resetViewState function
  2. Added resetViewState implementation to FreeSortListView.qml that calls positionViewAtBeginning
  3. Now resetViewState works consistently across all category types
  4. Previously resetViewState was only working for non-FreeCategory views

fix: 从 resetViewState 中移除类别检查

  1. 移除了 AppList.qml 中 resetViewState 函数对 FreeCategory 的条件检查
  2. 在 FreeSortListView.qml 中添加了 resetViewState 实现,调用 positionViewAtBeginning
  3. 现在 resetViewState 在所有类别类型中都能一致工作
  4. 之前 resetViewState 仅对非 FreeCategory 视图有效

Pms: BUG-335941

Summary by Sourcery

Bug Fixes:

  • Fix resetViewState to work for FreeCategory by removing the categoryType check in AppList.qml and adding a resetViewState implementation in FreeSortListView.qml.

@sourcery-ai

sourcery-ai Bot commented Sep 29, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR refactors the resetViewState logic to remove category-specific guards and adds a concrete implementation in FreeSortListView, ensuring the view state resets consistently for all category types.

Sequence diagram for resetViewState invocation across category types

sequenceDiagram
    participant AppList
    participant loaderItem as "loader.item (could be FreeSortListView)"
    AppList->>loaderItem: resetViewState()
    alt loader.item is FreeSortListView
        loaderItem->>loaderItem: positionViewAtBeginning()
    end
Loading

Class diagram for updated resetViewState logic

classDiagram
    class AppList {
        +resetViewState()
        +switchToFreeSort(freeSort)
    }
    class FreeSortListView {
        +resetViewState()
        +positionViewAtBeginning()
    }
    AppList --> FreeSortListView : uses loader.item
Loading

File-Level Changes

Change Details Files
Remove FreeCategory guard in resetViewState
  • Deleted conditional check for FreeCategory
  • Eliminated branch and unwrapped loader.item.resetViewState call
qml/windowed/AppList.qml
Introduce resetViewState in FreeSortListView
  • Added resetViewState function stub
  • Invoke positionViewAtBeginning within resetViewState
qml/windowed/FreeSortListView.qml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai 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.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@wjyrich wjyrich requested review from BLumia and yixinshark and removed request for yixinshark September 29, 2025 02:10
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, wjyrich

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1. Removed conditional check for FreeCategory in AppList.qml's
resetViewState function
2. Added resetViewState implementation to FreeSortListView.qml that
calls positionViewAtBeginning
3. Now resetViewState works consistently across all category types
4. Previously resetViewState was only working for non-FreeCategory views

fix: 从 resetViewState 中移除类别检查

1. 移除了 AppList.qml 中 resetViewState 函数对 FreeCategory 的条件检查
2. 在 FreeSortListView.qml 中添加了 resetViewState 实现,调用
positionViewAtBeginning
3. 现在 resetViewState 在所有类别类型中都能一致工作
4. 之前 resetViewState 仅对非 FreeCategory 视图有效

Pms: BUG-335941
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我来分析这段代码变更:

  1. AppList.qml 中:

    • 移除了 resetViewState() 函数中的条件判断
    • 直接调用 loader.item.resetViewState()
  2. FreeSortListView.qml 中:

    • 新增了 resetViewState() 函数
    • 函数内部调用 positionViewAtBeginning()

改进建议:

  1. 代码质量与逻辑:

    • 原代码中的条件判断被移除可能会导致潜在问题。原代码检查 CategorizedSortProxyModel.categoryType 确保只有在非自由分类模式下才调用重置,这是一个安全措施。直接移除这个检查可能会导致在自由分类模式下也执行不必要的重置操作。
    • 建议恢复条件判断,或者确保 FreeSortListViewresetViewState() 方法在所有情况下都是安全的。
  2. 代码健壮性:

    • loader.item 可能为 null,应该添加空值检查,避免潜在的运行时错误。
    • 建议修改为:
    function resetViewState() {
        if (loader && loader.item) {
            loader.item.resetViewState()
        }
    }
  3. 性能考虑:

    • 当前实现是合理的,positionViewAtBeginning() 是一个轻量级操作,不会造成性能问题。
  4. 代码安全:

    • 确保所有组件都正确实现了 resetViewState() 方法,避免未定义方法调用的错误。
    • 考虑添加文档注释,说明这些方法的用途和预期行为。
  5. 改进建议:

    • 建议恢复原来的条件检查,同时添加空值检查:
    function resetViewState() {
        if (loader && loader.item && CategorizedSortProxyModel.categoryType !== CategorizedSortProxyModel.FreeCategory) {
            loader.item.resetViewState()
        }
    }

总结:虽然代码变更看起来简化了实现,但移除了重要的安全检查。建议恢复条件判断并添加适当的空值检查,以确保代码的健壮性和安全性。

@wjyrich wjyrich merged commit d3f17a6 into linuxdeepin:master Sep 29, 2025
10 checks passed
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