Skip to content

Commit

Permalink
Ensure calendars see separate events
Browse files Browse the repository at this point in the history
Not having a unique UID causes issues in some calendar applications.

Similarly, there seemed to be odd mutation issues when doing a shallow clone.

We also only loop through the `VEVENT` objects, as these are the only ones we care about right now.
  • Loading branch information
RealOrangeOne committed May 1, 2024
1 parent 6319b2b commit 1578617
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions calmerge/calendars.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import asyncio
from copy import deepcopy
from datetime import timedelta
from uuid import uuid4

import icalendar
from aiocache import Cache
Expand Down Expand Up @@ -53,10 +55,12 @@ def create_offset_calendar_events(
Mutate a calendar and add additional events at given offsets
"""
new_components = []

for component in calendar.walk():
for component in calendar.walk("VEVENT"):
for days in duplicate_days:
day_component = component.copy()
day_component = deepcopy(component)

# Create a new ID so calendar software shows it as a different event
day_component["UID"] = str(uuid4())

shift_event_by_offset(day_component, timedelta(days=days))

Expand Down

0 comments on commit 1578617

Please # to comment.