Closed Bug 1654322 Opened 4 years ago Closed 4 years ago

adding a card in a mail list trigger event of adding a new card in the directory even if no new card was created in the process

Categories

(Thunderbird :: Address Book, defect)

defect

Tracking

(thunderbird_esr78 fixed, thunderbird80 fixed)

RESOLVED FIXED
81 Branch
Tracking Status
thunderbird_esr78 --- fixed
thunderbird80 --- fixed

People

(Reporter: gfritos, Assigned: darktrojan)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36 Edg/84.0.522.40

Steps to reproduce:

Actual results:

Event of adding a new contact in the addressbook is emitted.

Expected results:

The event must not have been emitted.

The problem is here : par of code from https://searchfox.org/comm-central/source/mailnews/addrbook/jsaddrbook/AddrBookMailingList.jsm#118

addCard(card) {
if (!card.primaryEmail) {
return card;
}
if (!self._parent.hasCard(card)) {
self._parent.addCard(card);
}
let insertStatement = self._parent._dbConnection.createStatement(
"REPLACE INTO list_cards (list, card) VALUES (:list, :card)"
);
insertStatement.params.list = self._uid;
insertStatement.params.card = card.UID;
insertStatement.execute();
MailServices.ab.notifyItemPropertyChanged(card, null, null, null);
MailServices.ab.notifyItemPropertyChanged(card, null, null, null);
MailServices.ab.notifyDirectoryItemAdded(self._parent, card);
MailServices.ab.notifyDirectoryItemAdded(this, card);
Services.obs.notifyObservers(
card,
"addrbook-list-member-added",
self._uid
);
insertStatement.finalize();
return card;
},

Event if :
self._parent.hasCard(card) is true
the event :
MailServices.ab.notifyDirectoryItemAdded(self._parent, card);
is emitted.

Blocks: tb78found

Geoff, please take this one

Assignee: nobody → geoff
Status: UNCONFIRMED → NEW
Ever confirmed: true

I think this has always been the case. It was in my test which ensured the new address book had the same behaviour as the old address book. Regardless, it is stupid, so let's get rid of it.

FYI reporter, in the future we'll only have the observer service notifications, so if you're using nsIAbListener you might want to migrate.

Attachment #9166190 - Flags: review?(khushil324)
Attachment #9166190 - Flags: approval-comm-esr78?
Comment on attachment 9166190 [details] [diff] [review]
1654322-onitemadded-mailinglist-1.diff

Review of attachment 9166190 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good to me.
Try-run: https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&revision=789dd7931f27a3f84a9a9cc63605833e7132db21
Attachment #9166190 - Flags: review?(khushil324) → review+
Attachment #9166190 - Flags: approval-comm-beta?

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/608120887e25
Stop erroneously firing onItemAdded when a contact is added to a mailing list. r=khushil

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
Comment on attachment 9166190 [details] [diff] [review]
1654322-onitemadded-mailinglist-1.diff

Approved for beta
Attachment #9166190 - Flags: approval-comm-beta? → approval-comm-beta+
Comment on attachment 9166190 [details] [diff] [review]
1654322-onitemadded-mailinglist-1.diff

[Triage Comment]
Approved for esr78
Attachment #9166190 - Flags: approval-comm-esr78? → approval-comm-esr78+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: