[gnome-shell/gnome-41] calendar: Fix inclusion of zero-length events
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-41] calendar: Fix inclusion of zero-length events
- Date: Sat, 11 Dec 2021 14:20:30 +0000 (UTC)
commit 2a726dd3c947e0a603adeb9f702fd6801ebc5d60
Author: Sebastian Keller <skeller gnome org>
Date: Thu Nov 4 14:09:03 2021 +0100
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>
(cherry picked from commit 225065367381252877bd54e25f7cdb8f71820ff5)
js/ui/calendar.js | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index f0d8622666..853136f07e 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -171,13 +171,26 @@ function _datesEqual(a, b) {
return true;
}
-function _dateIntervalsOverlap(a0, a1, b0, b1) {
- if (a1 <= b0)
+/**
+ * Checks whether an event overlaps a given interval
+ *
+ * @param {Date} e0 Beginning of the event
+ * @param {Date} e1 End of the event
+ * @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;
+
+ if (e1 <= i0)
return false;
- else if (b1 <= a0)
+ if (i1 <= e0)
return false;
- else
- return true;
+
+ return true;
}
// an implementation that reads data from a session bus service
@@ -343,7 +356,7 @@ class DBusEventSource extends EventSourceBase {
*_getFilteredEvents(begin, end) {
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;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]