[IncidenceTreeModel] Update UID if it was changed
ClosedPublic

Authored by poboiko on Mar 30 2020, 1:51 PM.

Details

Summary

If one creates a Todo inside KOrganizer, it sets some default generated UID.
Such UID can be changed by the resource afterwards. The model should handle this case.

This patch adds a simple check: if the uid has changed inside `onDataChange, then just update the hashes.

Test Plan
  1. Add a Todo to Google Tasklist
  2. Add a subtodo instantly (without reloading the view)
  3. (without patch) Subtodo is added at the top level (parent was not recognized)
  4. (with patch) Subtodo is added below the parent todo

Diff Detail

Repository
R76 PIM: Event Views
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
poboiko created this revision.Mar 30 2020, 1:51 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptMar 30 2020, 1:51 PM
poboiko requested review of this revision.Mar 30 2020, 1:51 PM
winterz accepted this revision.Apr 2 2020, 9:02 PM
winterz added a subscriber: winterz.

The code is ok. I admit I don't understand how this could happen. Google is changing the UID?

please put this into the release/20.04 branch and merge to master.

This revision is now accepted and ready to land.Apr 2 2020, 9:02 PM

The code is ok. I admit I don't understand how this could happen. Google is changing the UID?

Thanks!

Basically, yes. Google provides own UIDs to address the task via its API.
It works as follows:

  1. First, KOrganizer creates a task, and generates some default random UID for it. This task is added to the model, and to the Akonadi DB.
  2. Then, Akonadi calls itemAdded callback for Google Resource, which sends this task to Google servers (via KGAPI2::TaskCreateJob).
  3. When this job is done, Google returns us the UID of newly added task, which will be used to work with this task via its API.
  4. Google Resource then changes the UID of the task to the new one explicitly (item.setGid(task->uid()); new ItemModifyJob(item))
  5. After that, the ETM gets notified of the result, and changes the UID of an item.
This revision was automatically updated to reflect the committed changes.