Skip to content

fix: prevent duplicate dock requests #1204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2025

Conversation

wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Jul 25, 2025

  1. Added check for existing docked applications in requestDockByDesktopId
  2. Return false if application is already docked to avoid duplicate entries
  3. Improves user experience by preventing redundant dock requests
  4. Maintains cleaner taskbar state by avoiding duplicate icons

fix: 防止重复的dock请求

  1. 在requestDockByDesktopId中添加对已dock应用的检查
  2. 如果应用已经dock则返回false避免重复条目
  3. 通过防止冗余的dock请求提升用户体验
  4. 避免重复图标保持任务栏状态更整洁

Pms: BUG-315721

Summary by Sourcery

Prevent duplicate dock requests in TaskManager by adding a check for existing docked applications and returning false if already docked

Bug Fixes:

  • Return false in requestDockByDesktopId if the application is already docked to avoid duplicate entries

Enhancements:

  • Maintain a cleaner taskbar state by skipping redundant dock icons

1. Added check for existing docked applications in
requestDockByDesktopId
2. Return false if application is already docked to avoid duplicate
entries
3. Improves user experience by preventing redundant dock requests
4. Maintains cleaner taskbar state by avoiding duplicate icons

fix: 防止重复的dock请求

1. 在requestDockByDesktopId中添加对已dock应用的检查
2. 如果应用已经dock则返回false避免重复条目
3. 通过防止冗余的dock请求提升用户体验
4. 避免重复图标保持任务栏状态更整洁

Pms: BUG-315721
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @wjyrich - 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.

Copy link

sourcery-ai bot commented Jul 25, 2025

Reviewer's Guide

Reworks requestDockByDesktopId to check for existing docked applications before docking, returning false to prevent duplicate entries and redundant taskbar icons.

Sequence diagram for preventing duplicate dock requests

sequenceDiagram
    actor User
    participant TaskManager
    participant Taskbar
    User->>TaskManager: requestDockByDesktopId(desktopID)
    TaskManager->>TaskManager: desktopIdToAppId(desktopID)
    TaskManager->>TaskManager: IsDocked(appId)?
    alt Already docked
        TaskManager-->>User: return false
    else Not docked
        TaskManager->>TaskManager: RequestDock(appId)
        TaskManager-->>User: return result
    end
Loading

Class diagram for TaskManager dock request logic update

classDiagram
    class TaskManager {
        +bool requestDockByDesktopId(QString desktopID)
        -QString desktopIdToAppId(QString desktopID)
        -bool IsDocked(QString appId)
        -bool RequestDock(QString appId)
    }
Loading

File-Level Changes

Change Details Files
Prevent duplicate dock requests
  • Introduce local appId variable from desktopID
  • Add IsDocked(appId) check before docking
  • Return false when application is already docked
  • Move RequestDock call to after the dock check
panels/dock/taskmanager/taskmanager.cpp

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

@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见:

  1. 代码重复

    • requestDockByDesktopId函数中,desktopIdToAppId函数被调用两次,可以将其结果存储在一个变量中,以避免重复调用。
  2. 注释风格

    • 注释应该使用中文,并且格式统一,例如使用中文冒号和句号。
  3. 函数命名

    • requestDockByDesktopId函数中的参数名desktopID应该统一使用小写字母和下划线,例如desktop_id
  4. 逻辑清晰性

    • requestDockByDesktopId函数中,先检查应用是否已经在任务栏中,如果是则返回false,否则调用RequestDock函数。这种逻辑是合理的,但可以进一步优化,例如将IsDocked函数的调用放在RequestDock之前,以减少不必要的函数调用。
  5. 代码风格

    • requestDockByDesktopId函数中,if语句后面的空格应该保持一致,例如if (IsDocked(appId))
  6. 错误处理

    • RequestDock函数调用没有错误处理,如果调用失败应该有相应的错误处理机制。
  7. 代码可读性

    • requestDockByDesktopId函数中的注释应该更加详细,说明为什么需要检查应用是否已经在任务栏中,以及RequestDock函数的具体作用。

综合以上意见,代码可以修改如下:

bool TaskManager::requestDockByDesktopId(const QString& desktop_id)
{
    if (desktop_id.startsWith("internal/")) return false;

    QString app_id = desktopIdToAppId(desktop_id);

    // 检查应用是否已经在任务栏中,如果是则返回 false
    if (IsDocked(app_id)) 
        return false;

    return RequestDock(app_id);
}

以上修改提高了代码的可读性、可维护性和性能。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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

@wjyrich
Copy link
Contributor Author

wjyrich commented Jul 28, 2025

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Jul 28, 2025

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 62d3e7f into linuxdeepin:master Jul 28, 2025
9 of 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.

4 participants