Skip to content

Commit 222cd3d

Browse files
authored
fix: Notifications not displayed in the center cannot disappear after… (#1034)
* fix: Notifications not displayed in the center cannot disappear after timeout as title Log: as title Pms: BUG-303295 * fix: Staging notifications cannot disappear after timeout as title Log: as title Pms: BUG-303331
1 parent 7d130fd commit 222cd3d

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

panels/notification/bubble/bubblemodel.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ BubbleItem *BubbleModel::removeById(qint64 id)
145145
return nullptr;
146146
}
147147

148+
uint BubbleModel::getBubbleIdByStorageId(qint64 id) const
149+
{
150+
for (const auto &item : m_bubbles) {
151+
if (item->id() == id) {
152+
return item->bubbleId();
153+
}
154+
}
155+
156+
return 0;
157+
}
158+
148159
BubbleItem *BubbleModel::bubbleItem(int bubbleIndex) const
149160
{
150161
if (bubbleIndex < 0 || bubbleIndex >= items().count())

panels/notification/bubble/bubblemodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class BubbleModel : public QAbstractListModel
4949
Q_INVOKABLE void remove(int index);
5050
void remove(const BubbleItem *bubble);
5151
BubbleItem *removeById(qint64 id);
52+
uint getBubbleIdByStorageId(qint64 id) const;
5253
void clear();
5354

5455
BubbleItem *bubbleItem(int bubbleIndex) const;

panels/notification/bubble/bubblepanel.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,15 @@ void BubblePanel::addBubble(qint64 id)
132132
void BubblePanel::closeBubble(qint64 id)
133133
{
134134
const auto entity = m_accessor->fetchEntity(id);
135-
if (!entity.isValid())
136-
return;
135+
if (entity.isValid()) {
136+
id = entity.bubbleId();
137+
} else {
138+
id = m_bubbles->getBubbleIdByStorageId(id);
139+
}
137140

138-
id = entity.bubbleId();
139-
m_bubbles->removeById(id);
141+
if (id > 0) {
142+
m_bubbles->removeById(id);
143+
}
140144
}
141145

142146
void BubblePanel::onActionInvoked(qint64 id, uint bubbleId, const QString &actionId)

panels/notification/server/notificationmanager.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -471,18 +471,17 @@ void NotificationManager::updateEntityProcessed(const NotifyEntity &entity)
471471
}
472472
// "cancel"表示正在发送蓝牙文件,不需要发送到通知中心
473473
const auto bluetooth = entity.body().contains("%") && entity.actions().contains("cancel");
474-
const bool removeEntity = removed || !showInCenter || bluetooth;
475-
if (!removeEntity) {
474+
if (removed || !showInCenter || bluetooth) {
475+
// remove it from memory
476+
m_persistence->removeEntity(id);
477+
} else {
478+
// add to db and remove it form memory
476479
m_persistence->updateEntityProcessedType(id, entity.processedType());
477480
}
478481

479-
// notify state changed, and then remove entity
480482
Q_EMIT NotificationStateChanged(entity.id(), entity.processedType());
481-
if (removeEntity) {
482-
m_persistence->removeEntity(id);
483-
removePendingEntity(entity);
484-
}
485483

484+
removePendingEntity(entity);
486485
emitRecordCountChanged();
487486
}
488487

0 commit comments

Comments
 (0)