Closed Bug 955463 Opened 8 years ago Closed 8 years ago

Filter out empty contacts in Services.contacts.getContacts()

Categories

(Chat Core :: General, defect)

x86
Other
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: nhnt11, Assigned: nhnt11)

Details

Attachments

(1 file, 1 obsolete file)

*** Original post on bio 2026 at 2013-06-29 12:39:00 UTC ***

Tag.getContacts() also does this to ensure consumers don't receive empty contacts in the array.
Attached patch Filter empty contacts (obsolete) — Splinter Review
*** Original post on bio 2026 as attmnt 2538 at 2013-06-29 12:43:00 UTC was without comment, so any subsequent comment numbers will be shifted ***
Attachment #8354306 - Flags: review?(aleth)
Assignee: nobody → nhnt11
Status: NEW → ASSIGNED
Comment on attachment 8354306 [details] [diff] [review]
Filter empty contacts

*** Original change on bio 2026 attmnt 2538 at 2013-06-29 12:46:37 UTC ***

Bouncing the review to flo as I didn't know of the existence of empty contacts! I think it's r+ though.
Attachment #8354306 - Flags: review?(aleth) → review?(florian)
*** Original post on bio 2026 at 2013-06-29 13:40:29 UTC ***

Comment on attachment 8354306 [details] [diff] [review] (bio-attmnt 2538)
Filter empty contacts

>-    let contacts = [ContactsById[id] for (id in ContactsById)];
>+    let contacts = [ContactsById[id] for (id in ContactsById)].filter(function(c) !c._empty);

Try if this works instead:

let contacts = [ContactsById[id] for (id in ContactsById) if (!ContactsById[id]._empty)];

Reason: I expect that to avoid creating one array as the array comprehension should create the first one and the filter call will return a new (second) one too as filter doesn't mutate the array that it is working on.
*** Original post on bio 2026 as attmnt 2540 at 2013-06-29 16:03:00 UTC ***

Thanks for the tip!
Attachment #8354308 - Flags: review?(florian)
Comment on attachment 8354306 [details] [diff] [review]
Filter empty contacts

*** Original change on bio 2026 attmnt 2538 at 2013-06-29 16:03:42 UTC was without comment, so any subsequent comment numbers will be shifted ***
Attachment #8354306 - Attachment is obsolete: true
Attachment #8354306 - Flags: review?(florian)
Comment on attachment 8354308 [details] [diff] [review]
Use Mic's suggested syntax

*** Original change on bio 2026 attmnt 2540 at 2013-07-02 21:55:36 UTC ***

I think we should cleanup this _empty mess at some point (I suspect it's related to the Unknown protocol plugin not handling buddies 'yet'), but I see no reason to not match the existing behavior for this new method for now. r=me.
Attachment #8354308 - Flags: review?(florian) → review+
*** Original post on bio 2026 at 2013-07-02 23:38:17 UTC ***

http://hg.instantbird.org/instantbird/rev/b60f6cc1ddf2
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → 1.5
You need to log in before you can comment on or make changes to this bug.