[Notifications] Use Date.now() instead of new Date().getTime()

The former is slightly more efficient
wilder-5.24
Kai Uwe Broulik 5 years ago
parent 3416c0d1ed
commit c4ece0fc0f
  1. 2
      applets/notifications/package/contents/ui/FullRepresentation.qml
  2. 3
      applets/notifications/package/contents/ui/NotificationHeader.qml
  3. 2
      applets/notifications/package/contents/ui/global/Globals.qml
  4. 2
      applets/notifications/package/contents/ui/main.qml

@ -204,7 +204,7 @@ PlasmaComponents3.Page {
var sections = []; var sections = [];
// Show until time if valid but not if too far int he future // Show until time if valid but not if too far int he future
if (!isNaN(inhibitedUntil.getTime()) && inhibitedUntil.getTime() - new Date().getTime() < 100 * 24 * 60 * 60 * 1000 /* 1 year*/) { if (!isNaN(inhibitedUntil.getTime()) && inhibitedUntil.getTime() - Date.now() < 100 * 24 * 60 * 60 * 1000 /* 1 year*/) {
sections.push(i18nc("Do not disturb until date", "Until %1", sections.push(i18nc("Do not disturb until date", "Until %1",
KCoreAddons.Format.formatRelativeDateTime(inhibitedUntil, Locale.ShortFormat))); KCoreAddons.Format.formatRelativeDateTime(inhibitedUntil, Locale.ShortFormat)));
} }

@ -120,8 +120,7 @@ RowLayout {
return ""; return "";
} }
var now = new Date(); var deltaMinutes = Math.floor((Date.now() - time.getTime()) / 1000 / 60);
var deltaMinutes = Math.floor((now.getTime() - time.getTime()) / 1000 / 60);
if (deltaMinutes < 1) { if (deltaMinutes < 1) {
return ""; return "";
} }

@ -256,7 +256,7 @@ QtObject {
var inhibitedUntil = notificationSettings.notificationsInhibitedUntil; var inhibitedUntil = notificationSettings.notificationsInhibitedUntil;
if (!isNaN(inhibitedUntil.getTime())) { if (!isNaN(inhibitedUntil.getTime())) {
inhibited |= (new Date().getTime() < inhibitedUntil.getTime()); inhibited |= (Date.now() < inhibitedUntil.getTime());
} }
if (notificationSettings.notificationsInhibitedByApplication) { if (notificationSettings.notificationsInhibitedByApplication) {

@ -79,7 +79,7 @@ Item {
// Show until time if valid but not if too far in the future // Show until time if valid but not if too far in the future
// TODO check app inhibition, too // TODO check app inhibition, too
if (inhibitedUntilValid if (inhibitedUntilValid
&& inhibitedUntil.getTime() - new Date().getTime() < 100 * 24 * 60 * 60 * 1000 /* 100 days*/) { && inhibitedUntil.getTime() - Date.now() < 100 * 24 * 60 * 60 * 1000 /* 100 days*/) {
lines.push(i18n("Do not disturb until %1", lines.push(i18n("Do not disturb until %1",
KCoreAddons.Format.formatRelativeDateTime(inhibitedUntil, Locale.ShortFormat))); KCoreAddons.Format.formatRelativeDateTime(inhibitedUntil, Locale.ShortFormat)));
} else { } else {

Loading…
Cancel
Save