File tree Expand file tree Collapse file tree 4 files changed +26
-11
lines changed
Expand file tree Collapse file tree 4 files changed +26
-11
lines changed Original file line number Diff line number Diff 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+
148159BubbleItem *BubbleModel::bubbleItem (int bubbleIndex) const
149160{
150161 if (bubbleIndex < 0 || bubbleIndex >= items ().count ())
Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff line change @@ -132,11 +132,15 @@ void BubblePanel::addBubble(qint64 id)
132132void 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
142146void BubblePanel::onActionInvoked (qint64 id, uint bubbleId, const QString &actionId)
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments