@@ -103,12 +103,14 @@ uint NotificationManager::recordCount() const
103103
104104void NotificationManager::actionInvoked (qint64 id, uint bubbleId, const QString &actionKey)
105105{
106+ qInfo (notifyLog) << " Action invoked, bubbleId:" << bubbleId << " , id:" << id << " , actionKey" << actionKey;
106107 auto entity = m_persistence->fetchEntity (id);
107108 if (entity.isValid ()) {
109+ doActionInvoked (entity, actionKey);
110+
108111 entity.setProcessedType (NotifyEntity::Removed);
109112 updateEntityProcessed (entity);
110113 }
111- doActionInvoked (entity, actionKey);
112114
113115 Q_EMIT ActionInvoked (bubbleId, actionKey);
114116 Q_EMIT NotificationClosed (bubbleId, NotifyEntity::Closed);
@@ -257,19 +259,22 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const
257259 }
258260 }
259261
262+ qInfo (notifyLog) << " Notify done, bubbleId:" << entity.bubbleId () << " , id:" << entity.id ();
263+
260264 // If replaces_id is 0, the return value is a UINT32 that represent the notification.
261265 // If replaces_id is not 0, the returned value is the same value as replaces_id.
262- return replacesId == 0 ? entity.bubbleId () : replacesId ;
266+ return entity.bubbleId ();
263267}
264268void NotificationManager::CloseNotification (uint id)
265269{
266- // TODO If the notification no longer exists, an empty D-BUS Error message is sent back.
267- const auto entity = m_persistence->fetchLastEntity (id);
270+ auto entity = m_persistence->fetchLastEntity (id);
268271 if (entity.isValid ()) {
269- Q_EMIT NotificationStateChanged (entity.id (), entity.processedType ());
272+ entity.setProcessedType (NotifyEntity::Removed);
273+ updateEntityProcessed (entity);
270274 }
271275
272276 Q_EMIT NotificationClosed (id, NotifyEntity::Closed);
277+ qDebug (notifyLog) << " Close notify, bubbleId" << id << " , id:" << entity.id ();
273278}
274279
275280void NotificationManager::GetServerInformation (QString &name, QString &vendor, QString &version, QString &specVersion)
@@ -413,6 +418,7 @@ void NotificationManager::updateEntityProcessed(const NotifyEntity &entity)
413418 const auto bluetooth = entity.body ().contains (" %" ) && entity.actions ().contains (" cancel" );
414419 if (removed || !showInCenter || bluetooth) {
415420 m_persistence->removeEntity (id);
421+ removePendingEntity (entity);
416422 } else {
417423 m_persistence->updateEntityProcessedType (id, entity.processedType ());
418424 }
@@ -485,4 +491,18 @@ void NotificationManager::onHandingPendingEntities()
485491 }
486492}
487493
494+ void NotificationManager::removePendingEntity (const NotifyEntity &entity)
495+ {
496+ for (auto iter = m_pendingTimeoutEntities.begin (); iter != m_pendingTimeoutEntities.end ();) {
497+ const auto item = iter.value ();
498+ if (item != entity) {
499+ iter++;
500+ continue ;
501+ }
502+ m_pendingTimeoutEntities.erase (iter);
503+ onHandingPendingEntities ();
504+ break ;
505+ }
506+ }
507+
488508} // notification
0 commit comments