• Igor Poboiko's avatar
    [contacts] Fix ContactCreateJob with a photo · 7de9af3d
    Igor Poboiko authored
    Summary:
    When we run `ContactCreateJob`, the UID of a contact is not yet known.
    We can only add a photo only after we receive a reply from main create job.
    
    Also, since we also don't want the following race condition to trigger:
     1) Contact1 create request
     2) Contact1 reply, Photo1 change request, Contact2 create request
     3) Contact2 reply, Photo2 change request
     4) Photo1 reply (here both `currentContact` and `lastContact` is Contact2)
     5) Photo2 reply
    we only go for next contact after the previous has been fully procesed:
     1) Contact1 create request
     2) Contact1 reply, Photo1 change request
     3) Photo1 reply, Contact2 create request
     4) Contact2 reply, Photo2 change request
     5) Photo2 reply
    
    Test Plan:
    Without patch:
     1) Create a contact with photo inside KAddressBook
     2) Check Web UI: no photo is set, sometimes bunch of contacts get created (?)
    With patch:
     2) Observe a single contact with a proper photo being set
    
    Reviewers: dvratil
    
    Reviewed By: dvratil
    
    Subscribers: kde-pim
    
    Tags: #kde_pim
    
    Differential Revision: https://phabricator.kde.org/D28178
    7de9af3d
contactcreatejob.cpp 5.96 KB