Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions panels/notification/bubble/bubblemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,18 @@
return nullptr;
}

uint BubbleModel::getBubbleIdByStorageId(qint64 id) const

Check warning on line 148 in panels/notification/bubble/bubblemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'getBubbleIdByStorageId' is never used.
{
for (const auto &item : m_bubbles) {

Check warning on line 150 in panels/notification/bubble/bubblemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Variable 'item' can be declared as pointer to const
if (item->id() == id) {

Check warning on line 151 in panels/notification/bubble/bubblemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Consider using std::find_if algorithm instead of a raw loop.
return item->bubbleId();
}
}

return 0;
}

BubbleItem *BubbleModel::bubbleItem(int bubbleIndex) const

Check warning on line 159 in panels/notification/bubble/bubblemodel.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'bubbleItem' is never used.
{
if (bubbleIndex < 0 || bubbleIndex >= items().count())
return nullptr;
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