Skip to content

Commit

Permalink
fix: Notifications not displayed in the center cannot disappear after… (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
yixinshark authored Feb 18, 2025
1 parent 7d130fd commit 222cd3d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
11 changes: 11 additions & 0 deletions panels/notification/bubble/bubblemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ BubbleItem *BubbleModel::removeById(qint64 id)
return nullptr;
}

uint BubbleModel::getBubbleIdByStorageId(qint64 id) const
{
for (const auto &item : m_bubbles) {
if (item->id() == id) {
return item->bubbleId();
}
}

return 0;
}

BubbleItem *BubbleModel::bubbleItem(int bubbleIndex) const
{
if (bubbleIndex < 0 || bubbleIndex >= items().count())
Expand Down
1 change: 1 addition & 0 deletions panels/notification/bubble/bubblemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class BubbleModel : public QAbstractListModel
Q_INVOKABLE void remove(int index);
void remove(const BubbleItem *bubble);
BubbleItem *removeById(qint64 id);
uint getBubbleIdByStorageId(qint64 id) const;
void clear();

BubbleItem *bubbleItem(int bubbleIndex) const;
Expand Down
12 changes: 8 additions & 4 deletions panels/notification/bubble/bubblepanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,15 @@ void BubblePanel::addBubble(qint64 id)
void BubblePanel::closeBubble(qint64 id)
{
const auto entity = m_accessor->fetchEntity(id);
if (!entity.isValid())
return;
if (entity.isValid()) {
id = entity.bubbleId();
} else {
id = m_bubbles->getBubbleIdByStorageId(id);
}

id = entity.bubbleId();
m_bubbles->removeById(id);
if (id > 0) {
m_bubbles->removeById(id);
}
}

void BubblePanel::onActionInvoked(qint64 id, uint bubbleId, const QString &actionId)
Expand Down
13 changes: 6 additions & 7 deletions panels/notification/server/notificationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,18 +471,17 @@ void NotificationManager::updateEntityProcessed(const NotifyEntity &entity)
}
// "cancel"表示正在发送蓝牙文件,不需要发送到通知中心
const auto bluetooth = entity.body().contains("%") && entity.actions().contains("cancel");
const bool removeEntity = removed || !showInCenter || bluetooth;
if (!removeEntity) {
if (removed || !showInCenter || bluetooth) {
// remove it from memory
m_persistence->removeEntity(id);
} else {
// add to db and remove it form memory
m_persistence->updateEntityProcessedType(id, entity.processedType());
}

// notify state changed, and then remove entity
Q_EMIT NotificationStateChanged(entity.id(), entity.processedType());
if (removeEntity) {
m_persistence->removeEntity(id);
removePendingEntity(entity);
}

removePendingEntity(entity);
emitRecordCountChanged();
}

Expand Down

0 comments on commit 222cd3d

Please sign in to comment.