From 1e7db6c325439fb536d5aba6aac717601bb0c7ba Mon Sep 17 00:00:00 2001 From: Florian Boulay Date: Mon, 23 Feb 2026 17:37:39 +0100 Subject: [PATCH] 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 --- Scripts/python/src/calendar/khal-events.py | 1 + Services/Location/Calendar/Khal.qml | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Scripts/python/src/calendar/khal-events.py b/Scripts/python/src/calendar/khal-events.py index fc5abca76..6b545425d 100755 --- a/Scripts/python/src/calendar/khal-events.py +++ b/Scripts/python/src/calendar/khal-events.py @@ -55,6 +55,7 @@ def main(): '--json', 'calendar', '--json', 'description', '--json', 'location', + '--json', 'repeat-pattern', khal_start, duration ] diff --git a/Services/Location/Calendar/Khal.qml b/Services/Location/Calendar/Khal.qml index 3addbf519..a073db81c 100644 --- a/Services/Location/Calendar/Khal.qml +++ b/Services/Location/Calendar/Khal.qml @@ -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) + } } }