@@ -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);
@@ -253,19 +255,22 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const
253255 }
254256 }
255257
258+ qInfo (notifyLog) << " Notify done, bubbleId:" << entity.bubbleId () << " , id:" << entity.id ();
259+
256260 // If replaces_id is 0, the return value is a UINT32 that represent the notification.
257261 // If replaces_id is not 0, the returned value is the same value as replaces_id.
258- return replacesId == 0 ? entity.bubbleId () : replacesId ;
262+ return entity.bubbleId ();
259263}
260264void NotificationManager::CloseNotification (uint id)
261265{
262- // TODO If the notification no longer exists, an empty D-BUS Error message is sent back.
263- const auto entity = m_persistence->fetchLastEntity (id);
266+ auto entity = m_persistence->fetchLastEntity (id);
264267 if (entity.isValid ()) {
265- Q_EMIT NotificationStateChanged (entity.id (), entity.processedType ());
268+ entity.setProcessedType (NotifyEntity::Removed);
269+ updateEntityProcessed (entity);
266270 }
267271
268272 Q_EMIT NotificationClosed (id, NotifyEntity::Closed);
273+ qDebug (notifyLog) << " Close notify, bubbleId" << id << " , id:" << entity.id ();
269274}
270275
271276void NotificationManager::GetServerInformation (QString &name, QString &vendor, QString &version, QString &specVersion)
@@ -409,6 +414,7 @@ void NotificationManager::updateEntityProcessed(const NotifyEntity &entity)
409414 const auto bluetooth = entity.body ().contains (" %" ) && entity.actions ().contains (" cancel" );
410415 if (removed || !showInCenter || bluetooth) {
411416 m_persistence->removeEntity (id);
417+ removePendingEntity (entity);
412418 } else {
413419 m_persistence->updateEntityProcessedType (id, entity.processedType ());
414420 }
@@ -481,4 +487,18 @@ void NotificationManager::onHandingPendingEntities()
481487 }
482488}
483489
490+ void NotificationManager::removePendingEntity (const NotifyEntity &entity)
491+ {
492+ for (auto iter = m_pendingTimeoutEntities.begin (); iter != m_pendingTimeoutEntities.end ();) {
493+ const auto item = iter.value ();
494+ if (item != entity) {
495+ iter++;
496+ continue ;
497+ }
498+ m_pendingTimeoutEntities.erase (iter);
499+ onHandingPendingEntities ();
500+ break ;
501+ }
502+ }
503+
484504} // notification
0 commit comments