Skip to content

refactor: simplify notification action handling#1115

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
18202781743:master
May 8, 2025
Merged

refactor: simplify notification action handling#1115
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743
Copy link
Copy Markdown
Contributor

@18202781743 18202781743 commented May 8, 2025

  1. Removed manual action processing in NotifyAccessor and delegated
    to DataUpdater
  2. Added new actionInvoked method without bubbleId parameter to
    NotificationManager
  3. Simplified action handling logic by removing direct QProcess
    execution
  4. Added corresponding methods in NotifyserverApplet to support new
    action flow
  5. Improved code organization by separating action handling concerns

refactor: 简化通知操作处理逻辑

  1. 移除 NotifyAccessor 中的手动操作处理,委托给 DataUpdater
  2. 在 NotificationManager 中添加不带 bubbleId 参数的 actionInvoked 方法
  3. 通过移除直接 QProcess 执行简化操作处理逻辑
  4. 在 NotifyserverApplet 中添加对应方法以支持新的操作流程
  5. 通过分离操作处理关注点改进代码组织

Summary by Sourcery

Refactor notification action handling to simplify and improve code organization by delegating action processing and removing direct process execution

Enhancements:

  • Simplified notification action handling logic
  • Improved separation of concerns in action processing

Chores:

  • Removed direct QProcess execution for action handling
  • Updated method signatures to remove unnecessary parameters

@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

代码审查意见:

  1. 代码重构

    • NotifyAccessor::invokeAction函数中,移除了对hints的处理逻辑,直接调用m_dataUpdater的方法。这可能是为了简化代码,但需要确认这一改动是否符合功能需求。
    • NotificationManager::actionInvoked函数中,添加了一个新的重载函数,用于处理bubbleId参数。这可能会导致混淆,因为bubbleId参数在原始函数中并不存在。建议确认这一改动是否必要,并确保所有调用该函数的地方都进行了相应的更新。
  2. 日志记录

    • NotificationManager::actionInvoked函数中,移除了对bubbleId的日志记录。如果bubbleId对于调试或跟踪问题很重要,建议恢复这一日志记录。
  3. 代码重复

    • NotifyServerApplet::actionInvoked中,添加了一个新的重载函数,与NotificationManager::actionInvoked的签名相同。这可能会导致调用时的歧义。建议检查是否有必要添加这个重载函数,并确保所有调用都正确处理了bubbleId参数。
  4. 函数签名一致性

    • NotificationManagerNotifyServerApplet类中,actionInvoked函数的签名不一致。NotificationManager类中有一个接受bubbleId参数的版本,而NotifyServerApplet类中则没有。这可能会导致调用时的错误。建议统一这两个类的函数签名,或者在调用时进行适当的处理。
  5. 代码注释

    • 代码中没有添加足够的注释来解释为什么需要添加新的重载函数,或者为什么移除了对hints的处理逻辑。建议添加适当的注释来解释这些改动的原因。
  6. 安全性

    • NotifyAccessor::invokeAction函数中,直接从entity.hints()中获取并执行命令。如果hints中的值不受信任,这可能会导致安全漏洞。建议验证hints中的值,或者使用更安全的方式来执行命令。
  7. 性能

    • NotifyAccessor::invokeAction函数中,移除了对hints的遍历。如果hints中包含大量的数据,这可能会提高性能。建议评估这一改动对性能的影响,并确保没有引入其他潜在的性能问题。

综上所述,建议在合并这些改动之前,进行充分的测试和代码审查,以确保这些改动不会引入新的问题,并且符合项目的需求和规范。

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

Copy link
Copy Markdown

@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 @18202781743 - I've reviewed your changes - here's some feedback:

  • Consider using Qt::AutoConnection instead of Qt::DirectConnection for QMetaObject::invokeMethod if the target object might reside in a different thread than the caller.
  • The new actionInvoked(id, actionKey) pathway, exposed via NotifyServerApplet, does not emit ActionInvoked(bubbleId, ...) or NotificationClosed(bubbleId, ...) signals; ensure this is the intended behavior for its callers.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

QMetaObject::invokeMethod(m_manager, "actionInvoked", Qt::DirectConnection, Q_ARG(qint64, id), Q_ARG(uint, bubbleId), Q_ARG(QString, actionKey));
}

void NotifyServerApplet::actionInvoked(qint64 id, const QString &actionKey)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nitpick (bug_risk): Consistency in QMetaObject::invokeMethod argument types.

Use Q_ARG(const QString&, actionKey) instead of Q_ARG(QString, actionKey) so the meta-object invocation exactly matches the method signature.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 8, 2025

Reviewer's Guide

This pull request refactors notification action handling by centralizing logic and separating concerns. Action invocation in NotifyAccessor is now delegated to DataUpdater using QMetaObject::invokeMethod, replacing direct QProcess execution. A new actionInvoked method signature, omitting the bubbleId parameter, has been introduced in NotificationManager and NotifyServerApplet to simplify the action processing flow.

File-Level Changes

Change Details Files
Refactored NotifyAccessor to delegate action invocation to DataUpdater.
  • Removed manual parsing of notification hints and direct QProcess::startDetached execution for invoking actions.
  • Delegated action invocation to m_dataUpdater by calling its actionInvoked method via QMetaObject::invokeMethod.
panels/notification/center/notifyaccessor.cpp
Introduced new actionInvoked methods without the bubbleId parameter and updated callers.
  • Added a new Q_INVOKABLE method actionInvoked(qint64 id, const QString &actionKey) to NotificationManager (and its header) for handling actions without a bubbleId.
  • Modified the existing NotificationManager::actionInvoked(qint64 id, uint bubbleId, const QString &actionKey) to call the new overload, streamlining internal logic.
  • Added a corresponding public slot actionInvoked(qint64 id, const QString &actionKey) to NotifyServerApplet (and its header) to expose the new action invocation path.
panels/notification/server/notificationmanager.cpp
panels/notification/server/notificationmanager.h
panels/notification/server/notifyserverapplet.cpp
panels/notification/server/notifyserverapplet.h

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

1. Removed manual action processing in NotifyAccessor and delegated
to DataUpdater
2. Added new actionInvoked method without bubbleId parameter to
NotificationManager
3. Simplified action handling logic by removing direct QProcess
execution
4. Added corresponding methods in NotifyserverApplet to support new
action flow
5. Improved code organization by separating action handling concerns

refactor: 简化通知操作处理逻辑

1. 移除 NotifyAccessor 中的手动操作处理,委托给 DataUpdater
2. 在 NotificationManager 中添加不带 bubbleId 参数的 actionInvoked 方法
3. 通过移除直接 QProcess 执行简化操作处理逻辑
4. 在 NotifyserverApplet 中添加对应方法以支持新的操作流程
5. 通过分离操作处理关注点改进代码组织
@18202781743
Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
Copy link
Copy Markdown

deepin-bot Bot commented May 8, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot Bot merged commit d1facff into linuxdeepin:master May 8, 2025
7 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.

3 participants