jobisoft / CategoryManager

[Thunderbird Add-On] Category Manager for Thunderbird contacts, also supports category based contact groups.
Mozilla Public License 2.0
41 stars 13 forks source link

fix: clone the contact when creating all-contacts addressBook #91

Closed kxxt closed 1 year ago

kxxt commented 1 year ago

We should create a clone of the contact when creating the all-contacts address book because we intend to update them separately. It will become a footgun that is hard to debug if the virtual addressbook and real addressbook is referencing the same contact object.

jobisoft commented 1 year ago

Should we not instead try to use the references correctly? I guess adding and deleting contacts can stay as it is, but updating needs a second thought? It will double the data stored if we add clones.

kxxt commented 1 year ago

Should we not instead try to use the references correctly? I guess adding and deleting contacts can stay as it is, but updating needs a second thought? It will double the data stored if we add clones.

If the contact object is updated in the real address book first. Then when our code updates the virtual address book, the same contact object will get updated twice. So we need to ensure that our functions such as addContactToCategoryInCache works without bugs(IIRC some of these functions rely on the categories field in contact object) even if the categories field stored in the contact is already updated. We need to document this in the code. Feel free to choose one way you like.