mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
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:
@@ -55,6 +55,7 @@ def main():
|
||||
'--json', 'calendar',
|
||||
'--json', 'description',
|
||||
'--json', 'location',
|
||||
'--json', 'repeat-pattern',
|
||||
khal_start,
|
||||
duration
|
||||
]
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user