Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mkcal] Simplify rawExpandedEvents() by using upstrean OccurrenceIterator. #2

Merged
merged 2 commits into from Aug 13, 2021

Conversation

dcaliste
Copy link
Contributor

This has the consequence that it's not mandatory anymore to declare any exception recurrenceId as an exdatetime of the parent. The API of rawExpandedEvents() is modified to simplify it. The inclusion parameters were not used. The expansion time zone has also been removed, so returned start time and end time are always given in the system time zone. This allow to transparently handle the events declared in local time.

@chriadam and @pvuorela, the purpose of this MR is to simplify a lot the rawExpandedEvents() by relying on the upstream OccurrenceIterator. It requires to change the method API though. When looking where it is used, I find only mer-core/nemo-qml-plugin-calendar in calendarworker.cpp. There it is used without the inclusive parameters, so I removed them. It is also used with the system time zone, which is in my opinion the only value that makes sense. Assuming only system time zone is used to expand the events simplify the routine a lot and avoid all changes in date time that were previously done.

I've slightly updated the tests to use the new API and all of them are passing (except the all day deserialisation onethat is broken, but not related), particularly, they are also passing when specifying another time zone like in TZ=Asia/Ho_Chi_Minh ./tst_storage.

If you agree with the API change, I'll submit a MR in the QML plugin to update it also.

The last advantage of this MR (besides relying more on upstream methods, and removing lines from mKCal) is also very important : it removes the necessity to add occurrence exception recurrenceId as exDateTime in the parent. This necessity was contrary to the RFC, but used as a mean to get timesInInterval() of the parent not to return an event on the exception date time (OccurrenceIterator is filtering out the returned list of timeInInterval for us and makes this all transparent). This RFC violation created complications in sync code that needs to add the exDateTime when receiving a recurring event with exceptions and remove them when upsyncing.

That's the purpose of the second commit : it is removing the addition of the exDateTime in dissociateSingleOccurrence(). But because of legacy events stored with additional exDateTime, not all code from the sync plugins handling with removing the additionnal exDateTime can be removed at this time.

Last comment maybe : one may decide to rename the rawExpandedEvents() to rawExpandedIncidences() since upstream OccurrenceIterator is dealing on events, todos and journals.

There is a long comment history, see : https://git.sailfishos.org/mer-core/mkcal/merge_requests/66

@dcaliste dcaliste changed the title Exdate [mkcal] Simplify rawExpandedEvents() by using upstrean OccurrenceIterator. Jun 22, 2021
@chriadam
Copy link
Contributor

The one outstanding discussion from the previous MR was that now, if the client attempts to dissociate the same occurrence twice (i.e. create two exception occurrences at the same recurrenceId) it will fail at storage save() time instead of at dissociate() time.
I think this is fine, for now..

@llewelld @pvuorela any other concerns with this one?

@chriadam
Copy link
Contributor

David pointed out that this has the potential to transform a single-event error into a whole-sync-cycle error. In practice, it should not be a problem, but worth considering.

@dcaliste
Copy link
Contributor Author

To address this, I'm going to add a call to instances() in the dissociation code. If the calendar is properly populated already from the DB, it will recover the previous behaviour.

@dcaliste
Copy link
Contributor Author

I've added the instances() check in the dissociation code. I've renamed the rawExpandedEvents() with the new API into rawExpandedIncidences() but also put back the old rawExpandedEvents() API with a deprecation warning, in case it is used outside nemo-qml-plugin-calendar.

Once accepted, to avoid the warning, you should consider sailfishos/nemo-qml-plugin-calendar#3. In that MR, I'm also bringing up a discussion on the necessity to actually keep this rawExpandedIncidences() API, since it's now only a thin wrapper around the upstream OccurenceIterator.

@chriadam and @pvuorela, what do you think ? @flypig you may have also some advices ?

*/
ExpandedIncidenceList rawExpandedIncidences(const QDateTime &start, const QDateTime &end) const;
/**
Depreacted routine, kept for backward compatibility.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: typoed deprecated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected, thanks.

@pvuorela
Copy link
Contributor

pvuorela commented Jul 6, 2021

Once accepted, to avoid the warning, you should consider sailfishos/nemo-qml-plugin-calendar#3. In that MR, I'm also bringing up a discussion on the necessity to actually keep this rawExpandedIncidences() API, since it's now only a thin wrapper around the upstream OccurenceIterator.

Could make sense to indeed then just drop the method. I think it was added here when the calendar app was getting hacked together. More we get rid of our extra api the better.

@dcaliste
Copy link
Contributor Author

More we get rid of our extra api the better.

I cannot agree more ;)

So I've reworked the commits to simply remove the function. This requires to include sailfishos/nemo-qml-plugin-calendar#3 first.

This method is deprecated in favor of KCalendarCore::OccurrenceIterator.
By removing it, the convention to always add an occurrence
recurrenceId as an EXDATE is not necessary anymore since
the upstream iterator is dealing with exceptions internally.
@chriadam
Copy link
Contributor

So, are we all happy with this one now? In combination with sailfishos/nemo-qml-plugin-calendar#3

@pvuorela
Copy link
Contributor

I'm happy so let's merge.

@pvuorela pvuorela merged commit 99d2e2a into sailfishos:master Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants