Skip to content

Commit 2aea5ea

Browse files
committed
fix: bluetooth still entered notificationcenter
Filting bluetooth notification in DataAccessorProxy. pms: BUG-311617
1 parent c22bcd9 commit 2aea5ea

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

panels/notification/common/dataaccessorproxy.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ qint64 DataAccessorProxy::addEntity(const NotifyEntity &entity)
3838
if (entity.processedType() == NotifyEntity::NotProcessed) {
3939
return m_impl->addEntity(entity);
4040
} else {
41-
if (m_source && m_source->isValid()) {
41+
if (m_source && m_source->isValid() && !filterToSource(entity)) {
4242
return m_source->addEntity(entity);
4343
}
4444
}
@@ -63,10 +63,14 @@ void DataAccessorProxy::updateEntityProcessedType(qint64 id, int processedType)
6363
m_impl->updateEntityProcessedType(id, processedType);
6464
if (m_source && m_source->isValid()) {
6565
auto entity = m_impl->fetchEntity(id);
66-
const auto sId = m_source->addEntity(entity);
67-
if (sId > 0) {
66+
if (!filterToSource(entity)) {
67+
const auto sId = m_source->addEntity(entity);
68+
if (sId > 0) {
69+
m_impl->removeEntity(id);
70+
entity.setId(sId);
71+
}
72+
} else {
6873
m_impl->removeEntity(id);
69-
entity.setId(sId);
7074
}
7175
}
7276
return;
@@ -177,4 +181,11 @@ bool DataAccessorProxy::routerToSource(qint64 id, int processedType) const
177181
}
178182
return false;
179183
}
184+
185+
bool DataAccessorProxy::filterToSource(const NotifyEntity &entity) const
186+
{
187+
// "cancel"表示正在发送蓝牙文件,不需要发送到通知中心
188+
const auto bluetooth = entity.body().contains("%") && entity.actions().contains("cancel");
189+
return bluetooth;
190+
}
180191
}

panels/notification/common/dataaccessorproxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class DataAccessorProxy : public DataAccessor
4040

4141
private:
4242
bool routerToSource(qint64 id, int processedType) const;
43+
bool filterToSource(const NotifyEntity &entity) const;
4344

4445
private:
4546
DataAccessor *m_source = nullptr;

panels/notification/server/notificationmanager.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,7 @@ void NotificationManager::updateEntityProcessed(const NotifyEntity &entity)
472472
if (entity.hints().contains("x-deepin-ShowInNotifyCenter")) {
473473
showInCenter = entity.hints()["x-deepin-ShowInNotifyCenter"].toBool();
474474
}
475-
// "cancel"表示正在发送蓝牙文件,不需要发送到通知中心
476-
const auto bluetooth = entity.body().contains("%") && entity.actions().contains("cancel");
477-
if (removed || !showInCenter || bluetooth) {
475+
if (removed || !showInCenter) {
478476
// remove it from memory
479477
m_persistence->removeEntity(id);
480478
} else {

0 commit comments

Comments
 (0)