bitfireAT / ical4android

Allows usage of iCalendar files with the Android calendar provider
GNU General Public License v3.0
19 stars 10 forks source link

Fix removal of recurrence rules in exceptions of recurring events #154

Closed sunkup closed 3 months ago

sunkup commented 4 months ago

Purpose

Obsolete recurrence rules were not being removed from recurrence exceptions properly. This happens due to repairing single events right away, before "knowing" their exceptions. With this PR "removal of exceptions" is done only after all events have been created with all known exceptions. That is any repairs are done after completely reading an iCalendar and before writing.

Description

rfc2822 commented 3 months ago

It might be cleaner to repair all events at once, after all the exceptions have been found, before returning them in Event.eventsFromReader().

👍🏻 The Validator should be kind of an interface that validates and repairs events, but the calling code should not know details (like that it deals with rrules of exceptions or whatever).

So we should only expose the repair() and call it at the right time:

  1. after completely reading an iCalendar
  2. before writing an iCalendar

(which should be documented in KDoc of EventValidator)

Because we can't do everything we need from fromVEvent(), we should call repair() when the complete event is available. And then we can adapt the tests, too.

Would love if this PR would not only fix the issue, but also make event validation a bit more documented.