Fix: Khal event lasting multiple days

Multiple days events are now displayed only once. This fix is also
compatible with a previous fix, which was meant to deal with recurring
events.

fix #1908
This commit is contained in:
Florian Boulay
2026-02-23 17:37:39 +01:00
parent 341c5ee138
commit 1e7db6c325
2 changed files with 20 additions and 2 deletions
@@ -55,6 +55,7 @@ def main():
'--json', 'calendar',
'--json', 'description',
'--json', 'location',
'--json', 'repeat-pattern',
khal_start,
duration
]
+19 -2
View File
@@ -131,13 +131,16 @@ Singleton {
function parseEvents(text) {
const result = [];
const duplicates = new Set();
for (const line of text.split("\n")) {
if (!line.trim())
continue;
const dayEvents = JSON.parse(line);
for (const event of dayEvents) {
result.push({
if (event["repeat-pattern"] !== "") {
// if there is a repeat pattern, the event must be included each time
result.push({
uid: event.uid,
calendar: event.calendar,
summary: event.title,
@@ -145,7 +148,21 @@ Singleton {
end: parseTimestamp(event["end-long-full"]),
location: event.location,
description: event.description
});
});
}
else if (!duplicates.has(event.uid) ) {
// in any other cases, we must remove duplicates using the uid of the event
result.push({
uid: event.uid,
calendar: event.calendar,
summary: event.title,
start: parseTimestamp(event["start-long-full"]),
end: parseTimestamp(event["end-long-full"]),
location: event.location,
description: event.description
});
duplicates.add(event.uid)
}
}
}