Commit 84765ba6 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Notifier: don't show update notifications too often

BUG: 416193
BUG: 436927
parent db089e0d
......@@ -15,5 +15,9 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted
<default>false</default>
</entry>
<entry name="LastUnattendedTrigger" type="DateTime" />
<entry name="RequiredNotificationInterval" type="Int" >
<default code="true">60 * 60 * 24</default>
</entry>
<entry name="LastNotificationTime" type="DateTime" />
</group>
</kcfg>
......@@ -70,7 +70,7 @@ DiscoverNotifier::DiscoverNotifier(QObject *parent)
updateStatusNotifier();
// Only fetch updates after the system is comfortably booted
QTimer::singleShot(20s, this, &DiscoverNotifier::recheckSystemUpdateNeeded);
QTimer::singleShot(0s, this, &DiscoverNotifier::recheckSystemUpdateNeeded);
}
DiscoverNotifier::~DiscoverNotifier() = default;
......@@ -110,6 +110,17 @@ void DiscoverNotifier::showUpdatesNotification()
return;
}
if (m_settings->requiredNotificationInterval() < 0) {
return;
}
// To configure to a random value, execute:
// kwriteconfig5 --file PlasmaDiscoverUpdates --group Global --key RequiredNotificationInterval 3600
const QDateTime timeSinceLastRefresh = m_settings->lastNotificationTime().addSecs(m_settings->requiredNotificationInterval());
if (!timeSinceLastRefresh.isValid() || timeSinceLastRefresh > QDateTime::currentDateTimeUtc()) {
return;
}
m_updatesAvailableNotification = KNotification::event(QStringLiteral("Update"),
message(),
{},
......@@ -124,6 +135,8 @@ void DiscoverNotifier::showUpdatesNotification()
connect(m_updatesAvailableNotification, QOverload<unsigned int>::of(&KNotification::activated), this, [this] {
showDiscoverUpdates(m_updatesAvailableNotification->xdgActivationToken());
});
m_settings->setLastNotificationTime(QDateTime::currentDateTimeUtc());
m_settings->save();
}
void DiscoverNotifier::updateStatusNotifier()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment