Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #13487 from wanderview/contacts-avoid-imgloader-re…
Browse files Browse the repository at this point in the history
…load

Bug 936202: Defer imgLoader.reload() when inserting contacts.  r=jmcf
  • Loading branch information
Ben Kelly committed Nov 8, 2013
2 parents fbfcc8a + 3b22e09 commit dcdf1c5
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions apps/communications/contacts/js/views/list.js
Expand Up @@ -12,6 +12,7 @@ contacts.List = (function() {
settingsView,
noContacts,
imgLoader = null,
needImgLoaderReload = false,
orderByLastName = null,
photoTemplate,
headers = {},
Expand Down Expand Up @@ -114,6 +115,16 @@ contacts.List = (function() {
renderPhoto(row, id);
updateSingleRowSelection(row, id);
}

// Since imgLoader.reload() causes sync reflows we only want to make this
// call when something happens that affects our onscreen view. Therefore
// we defer the call until here when we know the visibility monitor has
// detected a change and called onscreen().
if (imgLoader && needImgLoaderReload) {
needImgLoaderReload = false;
imgLoader.reload();
}

monitor.resumeMonitoringMutations(false);
};

Expand Down Expand Up @@ -1083,9 +1094,16 @@ contacts.List = (function() {
addToGroup(cloned, list);
}
toggleNoContactsScreen(false);
FixedHeader.refresh();
if (imgLoader)
imgLoader.reload();

// Avoid calling imgLoader.reload() here because it causes a sync reflow
// of the entire list. Ideally it would only do this if the new contact
// was added on screen or earlier, but unfortunately it doesn't have
// enough information. The visibility monitor, however, does have this
// information. Therefore set a flag here and then defer the reload until
// the next monitor onscreen() call.
if (imgLoader) {
needImgLoaderReload = true;
}

// When we add a new contact to the list we will by default
// select it depending on this two cases:
Expand Down

0 comments on commit dcdf1c5

Please sign in to comment.