Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[nemo-qml-plugin-calendar] Purge deleted local events. Contributes to…
… JB#52656

Local calendar events are never synced anywhere, so we can purge them
rather than merely marking them as deleted, in order to avoid them
remaining in the database (along with their reminder alarms).

Note that the purgeDeletedIncidences() call must occur after the call
to ExtendedStorage::save() in order to work correctly.
  • Loading branch information
chriadam committed Jan 12, 2021
1 parent 174558d commit c1870c3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/calendarworker.cpp
Expand Up @@ -193,11 +193,17 @@ void CalendarWorker::save()
if (!mDeletedEvents.isEmpty()) {
for (const QPair<QString, QDateTime> &pair: mDeletedEvents) {
KCalendarCore::Event::Ptr event = mCalendar->deletedEvent(pair.first, pair.second);
if (!needSendCancellation(event)) {
continue;
if (needSendCancellation(event)) {
event->setStatus(KCalendarCore::Incidence::StatusCanceled);
mKCal::ServiceHandler::instance().sendUpdate(event, QString(), mCalendar, mStorage);
}
// if the event was stored in a local (non-synced) notebook, purge it.
const QString notebookUid = mCalendar->notebook(event);
const mKCal::Notebook::Ptr notebook = mStorage->notebook(notebookUid);
if (!notebook.isNull() && notebook->pluginName().isEmpty() && notebook->account().isEmpty()
&& !mStorage->purgeDeletedIncidences(KCalendarCore::Incidence::List() << event)) {
qWarning() << "Failed to purge deleted event " << event->uid() << " from local calendar " << notebookUid;
}
event->setStatus(KCalendarCore::Incidence::StatusCanceled);
mKCal::ServiceHandler::instance().sendUpdate(event, QString(), mCalendar, mStorage);
}
mDeletedEvents.clear();
}
Expand Down

0 comments on commit c1870c3

Please sign in to comment.