Skip to content

Commit eb8cae7

Browse files
committed
fix: update replace notification entity expired time
as title Log: as title Bug: PMS-296507
1 parent fc4eb8b commit eb8cae7

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

panels/notification/server/notificationmanager.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const
254254

255255
if (entity.processedType() != NotifyEntity::None) {
256256
qint64 id = -1;
257+
bool isReplace = false;
257258
if (entity.isReplace()) {
259+
isReplace = true;
258260
auto lastEntity = m_persistence->fetchLastEntity(entity.bubbleId());
259261
if (lastEntity.isValid()) {
260262
removePendingEntity(entity);
@@ -284,7 +286,7 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const
284286
}
285287
// 0: never expire. -1: DefaultTimeOutMSecs
286288
if (expireTimeout != 0 && !critical) {
287-
pushPendingEntity(entity, expireTimeout);
289+
pushPendingEntity(entity, expireTimeout, isReplace);
288290
}
289291
}
290292

@@ -415,8 +417,18 @@ void NotificationManager::emitRecordCountChanged()
415417
emit RecordCountChanged(count);
416418
}
417419

418-
void NotificationManager::pushPendingEntity(const NotifyEntity &entity, int expireTimeout)
420+
void NotificationManager::pushPendingEntity(const NotifyEntity &entity, int expireTimeout, bool isReplace)
419421
{
422+
if (isReplace) {
423+
for (auto iter = m_pendingTimeoutEntities.begin(); iter != m_pendingTimeoutEntities.end();) {
424+
if (iter.value().bubbleId() == entity.bubbleId()) {
425+
m_pendingTimeoutEntities.erase(iter);
426+
break;
427+
}
428+
++iter;
429+
}
430+
}
431+
420432
const int interval = expireTimeout == -1 ? DefaultTimeOutMSecs : expireTimeout;
421433

422434
qint64 point = QDateTime::currentMSecsSinceEpoch() + interval;

panels/notification/server/notificationmanager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public Q_SLOTS:
7272
void tryPlayNotificationSound(const NotifyEntity &entity, const QString &appId, bool dndMode) const;
7373
void emitRecordCountChanged();
7474

75-
void pushPendingEntity(const NotifyEntity &entity, int expireTimeout);
75+
void pushPendingEntity(const NotifyEntity &entity, int expireTimeout, bool isReplace);
7676
void updateEntityProcessed(qint64 id, uint reason);
7777
void updateEntityProcessed(const NotifyEntity &entity);
7878

0 commit comments

Comments
 (0)