Skip to content

Commit

Permalink
[lipstick] Use summary and body as fallbacks for their preview equiva…
Browse files Browse the repository at this point in the history
…lents. JB#50564
  • Loading branch information
Bea Lam committed Jul 27, 2020
1 parent d45dd73 commit 058d26a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/notifications/notificationmanager.cpp
Expand Up @@ -303,10 +303,11 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const

notification->restartProgressTimer();

const QString previewSummary(hints_.value(LipstickNotification::HINT_PREVIEW_SUMMARY).toString());
const QString previewBody(hints_.value(LipstickNotification::HINT_PREVIEW_BODY).toString());

if (androidOrigin) {
// If this notification includes a preview, ensure it has a non-empty body and summary
const QString previewSummary(hints_.value(LipstickNotification::HINT_PREVIEW_SUMMARY).toString());
const QString previewBody(hints_.value(LipstickNotification::HINT_PREVIEW_BODY).toString());
if (!previewSummary.isEmpty()) {
if (previewBody.isEmpty()) {
hints_.insert(LipstickNotification::HINT_PREVIEW_BODY, QStringLiteral(" "));
Expand Down Expand Up @@ -344,6 +345,15 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const
hints_.insert(LipstickNotification::HINT_APP_ICON, pidProperties.second);
}

// Use the summary and body as fallback values for previewSummary and previewBody.
// (This can be avoided by setting them explicitly to empty strings.)
if (!hints_.contains(LipstickNotification::HINT_PREVIEW_SUMMARY)) {
hints_.insert(LipstickNotification::HINT_PREVIEW_SUMMARY, summary);
}
if (!hints_.contains(LipstickNotification::HINT_PREVIEW_BODY)) {
hints_.insert(LipstickNotification::HINT_PREVIEW_BODY, body);
}

// Unspecified priority should result in medium priority to permit low priorities
if (!hints_.contains(LipstickNotification::HINT_PRIORITY)) {
hints_.insert(LipstickNotification::HINT_PRIORITY, DefaultNotificationPriority);
Expand Down

0 comments on commit 058d26a

Please sign in to comment.