calendar: Fix inclusion of zero-length events
Events with a date time (not just a date) where the end time is missing or matching the start time were considered to not overlap the selected interval if they were happening on the start time of the interval. This was causing such zero-length events to be omitted from the calendar if they were starting at 0:00. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2023>
This commit is contained in:
parent
9604778343
commit
2250653673
@ -171,13 +171,26 @@ function _datesEqual(a, b) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _dateIntervalsOverlap(a0, a1, b0, b1) {
|
/**
|
||||||
if (a1 <= b0)
|
* Checks whether an event overlaps a given interval
|
||||||
return false;
|
*
|
||||||
else if (b1 <= a0)
|
* @param {Date} e0 Beginning of the event
|
||||||
return false;
|
* @param {Date} e1 End of the event
|
||||||
else
|
* @param {Date} i0 Beginning of the interval
|
||||||
|
* @param {Date} i1 End of the interval
|
||||||
|
* @returns {boolean} Whether there was an overlap
|
||||||
|
*/
|
||||||
|
function _eventOverlapsInterval(e0, e1, i0, i1) {
|
||||||
|
// This also ensures zero-length events are included
|
||||||
|
if (e0 >= i0 && e1 < i1)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (e1 <= i0)
|
||||||
|
return false;
|
||||||
|
if (i1 <= e0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// an implementation that reads data from a session bus service
|
// an implementation that reads data from a session bus service
|
||||||
@ -343,7 +356,7 @@ class DBusEventSource extends EventSourceBase {
|
|||||||
|
|
||||||
*_getFilteredEvents(begin, end) {
|
*_getFilteredEvents(begin, end) {
|
||||||
for (const event of this._events.values()) {
|
for (const event of this._events.values()) {
|
||||||
if (_dateIntervalsOverlap(event.date, event.end, begin, end))
|
if (_eventOverlapsInterval(event.date, event.end, begin, end))
|
||||||
yield event;
|
yield event;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user