saegl5 / jiayou_add_events

Batch create calendar events on only certain letter days that spell out words of encouragement.
Other
0 stars 1 forks source link

Events disappear when edited for "this and following events" #2

Closed saegl5 closed 3 days ago

saegl5 commented 4 days ago

@jmarmstrong1207

A fellow colleague brought to my attention, and I was able to replicate, that events disappear when edited for "this and following events." You can still search for them, but they no longer display on the calendar. I tried editing one event and saving for all events, nevertheless some events still won't display on the calendar...it's as if they enter a void. (Yes, we can still search and delete all events as a series, but...)

Additional testing: Events don't disappear when edited for "this event" or "all events." In fact, the events stay chained. I can edit an event that has a different title than all other events, save the edit for all events, and its and all the other events' titles change in tandem.

Are you able to replicate this, too? I tested using your merged commit (2baccd2e3e1f2aee58c7a5fc524e6ee531c35c86) and my latest commit (639ae6f654e2ce9e6b8ea6193905e83b5fa5f36d), same outcome

saegl5 commented 4 days ago

I think what is happening is that, because when we change an event from Google Calendar and we can't choose to repeat the event a normal way (daily, weekly, monthly, etc.), when we press save for "this and following events" then Google Calendar doesn't know how to handle the events.

CORRECTION: Google Calendar does know how to handle such events

jmarmstrong1207 commented 4 days ago

I'm also able to reproduce this bug. Deleting works perfectly fine though. I'm using standard google API functions, so I feel like I implemented it wrong somewhere. Looking into it

saegl5 commented 4 days ago

I'm also able to reproduce this bug. Deleting works perfectly fine though. I'm using standard google API functions, so I feel like I implemented it wrong somewhere. Looking into it

Thank you for following up~~ Sure, see what you can find. I'll look too. I do think you implemented it correctly, though... CORRECTION: I should have set the dateStartTime and dateEndTime in setRecurrence() to be the first of each before I merged the commit.

Regarding deleting, unfortunately I also noticed that if you delete events from "this and following events"---regardless if they had also been edited using "this and following events,"---Google Calendar also exhibits strange behavior: The last event in a series re-appears in the calendar.

At the very least, until either we find a solution or---if Google Calendar doesn't support recurring events that don't follow standard RRule patterns---until they do support such events, we can still use scripts for creating, adding, updating and deleting individual events. Not as friendly, but they did work never mind, solution found, and Google Calendar does support such events

saegl5 commented 4 days ago

UPDATE:

Google Calendar does follow RFC 5545 (source: https://developers.google.com/calendar/api/concepts/events-calendars), but its user interface for creating/editing events has no option for RDATE or EXDATE, only RRULE (daily, weekly, monthly, etc.) Meaning also that RDATE (what we are using) is not fully implemented. still true

.......Maybe we could convert the adding-events Web app to an add-on like Custom Recurrence (https://workspace.google.com/u/0/marketplace/app/custom_recurrence/191593173483) could still do, but no longer relevant to this discussion

I'll pause for now

saegl5 commented 4 days ago

@jmarmstrong1207 I think I found the problem!

say you add a new event series (not edited yet!) and you export the calendar containing the event series, open the exported .ics file in TextEdit/Notepad, and search for the event series details, you would see that the DTSTART and DTEND will be on the last day of the event series (e.g., 20241030T100000)

BEGIN:VEVENT
DTSTART;TZID=America/Los_Angeles:20241030T100000
DTEND;TZID=America/Los_Angeles:20241030T110000
DTSTAMP:20240926T052944Z
UID:1ce6hphr2mhqk5okp74224o3c8@google.com
CREATED:20240926T052838Z
LAST-MODIFIED:20240926T052839Z
SEQUENCE:3
STATUS:CONFIRMED
SUMMARY:New Meeting
TRANSP:OPAQUE
RDATE;TZID=America/Los_Angeles:20241001T100000
RDATE;TZID=America/Los_Angeles:20241009T100000
RDATE;TZID=America/Los_Angeles:20241022T100000
RDATE;TZID=America/Los_Angeles:20241030T100000
END:VEVENT

DTSTART and DTEND should be on 20241001T100000 (sources: https://developers.google.com/apps-script/reference/calendar/calendar-event-series#setrecurrencerecurrence,-starttime,-endtime and https://datatracker.ietf.org/doc/html/rfc5545#section-3.8.5.2)

So, what happened?

I believe that when we chained subsequent events to the first event... eventSeries.setRecurrence(CalendarApp.newRecurrence().addDate(eventDate), dateStartTime, dateEndTime) (line 157 of commit 2baccd2e3e1f2aee58c7a5fc524e6ee531c35c86)

...dateStartTime and dateEndTime were supposed to be for the first event only, however their values kept getting re-assigned each time the for loop (line 121) repeated

so, I fixed assigned their values to be values for the first event only, redeployed, added a new event series, re-tested, and the events no longer disappear from the calendar

jmarmstrong1207 commented 3 days ago

I implemented your problem in PR #3, and it works perfectly now! Editing has no issues for me. thank you so much for finding this out.

saegl5 commented 3 days ago

I implemented your problem in PR #3, and it works perfectly now! Editing has no issues for me. thank you so much for finding this out.

closing the issue, will work on your pr