From 39080c14f232e5572567311b515d30d489d70757 Mon Sep 17 00:00:00 2001 From: Ye ShanShan Date: Mon, 14 Apr 2025 17:42:51 +0800 Subject: [PATCH] fix: bluetooth still entered notificationcenter Filting bluetooth notification in DataAccessorProxy. pms: BUG-311617 --- .../notification/common/dataaccessorproxy.cpp | 19 +++++++++++++++---- .../notification/common/dataaccessorproxy.h | 1 + .../server/notificationmanager.cpp | 4 +--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/panels/notification/common/dataaccessorproxy.cpp b/panels/notification/common/dataaccessorproxy.cpp index fdb425841..095d353bf 100644 --- a/panels/notification/common/dataaccessorproxy.cpp +++ b/panels/notification/common/dataaccessorproxy.cpp @@ -38,7 +38,7 @@ qint64 DataAccessorProxy::addEntity(const NotifyEntity &entity) if (entity.processedType() == NotifyEntity::NotProcessed) { return m_impl->addEntity(entity); } else { - if (m_source && m_source->isValid()) { + if (m_source && m_source->isValid() && !filterToSource(entity)) { return m_source->addEntity(entity); } } @@ -63,10 +63,14 @@ void DataAccessorProxy::updateEntityProcessedType(qint64 id, int processedType) m_impl->updateEntityProcessedType(id, processedType); if (m_source && m_source->isValid()) { auto entity = m_impl->fetchEntity(id); - const auto sId = m_source->addEntity(entity); - if (sId > 0) { + if (!filterToSource(entity)) { + const auto sId = m_source->addEntity(entity); + if (sId > 0) { + m_impl->removeEntity(id); + entity.setId(sId); + } + } else { m_impl->removeEntity(id); - entity.setId(sId); } } return; @@ -177,4 +181,11 @@ bool DataAccessorProxy::routerToSource(qint64 id, int processedType) const } return false; } + +bool DataAccessorProxy::filterToSource(const NotifyEntity &entity) const +{ + // "cancel"表示正在发送蓝牙文件,不需要发送到通知中心 + const auto bluetooth = entity.body().contains("%") && entity.actions().contains("cancel"); + return bluetooth; +} } diff --git a/panels/notification/common/dataaccessorproxy.h b/panels/notification/common/dataaccessorproxy.h index 05a57b82b..764ffc86a 100644 --- a/panels/notification/common/dataaccessorproxy.h +++ b/panels/notification/common/dataaccessorproxy.h @@ -40,6 +40,7 @@ class DataAccessorProxy : public DataAccessor private: bool routerToSource(qint64 id, int processedType) const; + bool filterToSource(const NotifyEntity &entity) const; private: DataAccessor *m_source = nullptr; diff --git a/panels/notification/server/notificationmanager.cpp b/panels/notification/server/notificationmanager.cpp index 508c9b5e7..26c034b30 100644 --- a/panels/notification/server/notificationmanager.cpp +++ b/panels/notification/server/notificationmanager.cpp @@ -472,9 +472,7 @@ void NotificationManager::updateEntityProcessed(const NotifyEntity &entity) if (entity.hints().contains("x-deepin-ShowInNotifyCenter")) { showInCenter = entity.hints()["x-deepin-ShowInNotifyCenter"].toBool(); } - // "cancel"表示正在发送蓝牙文件,不需要发送到通知中心 - const auto bluetooth = entity.body().contains("%") && entity.actions().contains("cancel"); - if (removed || !showInCenter || bluetooth) { + if (removed || !showInCenter) { // remove it from memory m_persistence->removeEntity(id); } else {