Commit a05dc73c authored by Eugene Popov's avatar Eugene Popov Committed by Nate Graham

[applets/digital-clock] Fix calendar events not being shown at first

Summary:
I noticed that on the first time I bring up the calendar by clicking the clock on my Plasma panel, it always shows "No event for today". If I click another day on the calendar and then click back on today, it shows today's events fine. It should display it correctly the first time.

To fix this bug, we need to compare the date without time.

BUG: 395956
FIXED-IN: 5.19.0

Reviewers: ngraham, #plasma, vkrause

Reviewed By: ngraham

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D28354
parent 804782df
......@@ -151,6 +151,24 @@ Item {
return Qt.formatDate(date, format);
}
function dateEquals(date1, date2) {
var values1 = [
date1.getFullYear(),
date1.getMonth(),
date1.getDate()
];
var values2 = [
date2.getFullYear(),
date2.getMonth(),
date2.getDate()
];
return values1.every((value, index) => {
return (value === values2[index]);
}, false)
}
Connections {
target: monthView
......@@ -170,10 +188,7 @@ Item {
target: monthView.daysModel
onAgendaUpdated: {
// Checks if the dates are the same, comparing the date objects
// directly won't work and this does a simple integer subtracting
// so should be fastest. One of the JS weirdness.
if (updatedDate - monthView.currentDate === 0) {
if (agenda.dateEquals(updatedDate, monthView.currentDate)) {
holidaysList.model = null;
holidaysList.model = monthView.daysModel.eventsForDate(monthView.currentDate);
}
......
Markdown is supported
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