Commit fcd7852f authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview Componentization: Update destinations more efficiently

Use ListPropertyUpdateBehavior to avoid always changing the full list
when new destinations load. Observed a ~10% improvement in time to
refresh the list when cloud destinations were added to destination
store.

Bug: 773928
Cq-Include-Trybots: luci.chromium.try:closure_compilation
Change-Id: I11c00701c8c3dd1c8f3bf06937a72d3640ff43c5
Reviewed-on: https://chromium-review.googlesource.com/1141083
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575962}
parent ec103cf0
...@@ -296,6 +296,7 @@ js_library("destination_dialog") { ...@@ -296,6 +296,7 @@ js_library("destination_dialog") {
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog", "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
"//ui/webui/resources/js:event_tracker", "//ui/webui/resources/js:event_tracker",
"//ui/webui/resources/js:i18n_behavior", "//ui/webui/resources/js:i18n_behavior",
"//ui/webui/resources/js:list_property_update_behavior",
] ]
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<link rel="import" href="chrome://resources/html/action_link_css.html"> <link rel="import" href="chrome://resources/html/action_link_css.html">
<link rel="import" href="chrome://resources/html/event_tracker.html"> <link rel="import" href="chrome://resources/html/event_tracker.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html"> <link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/html/list_property_update_behavior.html">
<link rel="import" href="../metrics.html"> <link rel="import" href="../metrics.html">
<link rel="import" href="../print_preview_utils.html"> <link rel="import" href="../print_preview_utils.html">
<link rel="import" href="../data/destination.html"> <link rel="import" href="../data/destination.html">
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
Polymer({ Polymer({
is: 'print-preview-destination-dialog', is: 'print-preview-destination-dialog',
behaviors: [I18nBehavior], behaviors: [I18nBehavior, ListPropertyUpdateBehavior],
properties: { properties: {
/** @type {?print_preview.DestinationStore} */ /** @type {?print_preview.DestinationStore} */
...@@ -149,9 +149,15 @@ Polymer({ ...@@ -149,9 +149,15 @@ Polymer({
if (this.userInfo.loggedIn) if (this.userInfo.loggedIn)
this.showCloudPrintPromo = false; this.showCloudPrintPromo = false;
this.destinations_ = this.userInfo ? if (this.userInfo) {
this.destinationStore.destinations(this.userInfo.activeUser) : this.updateList(
[]; 'destinations_',
destination => destination.origin + '/' + destination.id,
this.destinationStore.destinations(this.userInfo.activeUser));
} else {
this.destinations_ = [];
}
this.loadingDestinations_ = this.loadingDestinations_ =
this.destinationStore.isPrintDestinationSearchInProgress; this.destinationStore.isPrintDestinationSearchInProgress;
}, },
......
...@@ -12,10 +12,7 @@ Polymer({ ...@@ -12,10 +12,7 @@ Polymer({
properties: { properties: {
/** @type {Array<!print_preview.Destination>} */ /** @type {Array<!print_preview.Destination>} */
destinations: { destinations: Array,
type: Array,
observer: 'destinationsChanged_',
},
/** @type {boolean} */ /** @type {boolean} */
hasActionLink: { hasActionLink: {
...@@ -57,9 +54,16 @@ Polymer({ ...@@ -57,9 +54,16 @@ Polymer({
}, },
}, },
observers: [
'destinationsChanged_(destinations.*)',
],
/** @private {boolean} */ /** @private {boolean} */
newDestinations_: false, newDestinations_: false,
/** @private {boolean} */
initializedDestinations_: false,
/** @private {!Array<!Node>} */ /** @private {!Array<!Node>} */
highlights_: [], highlights_: [],
...@@ -68,9 +72,10 @@ Polymer({ ...@@ -68,9 +72,10 @@ Polymer({
* @param {?Array<!print_preview.Destination>} previous * @param {?Array<!print_preview.Destination>} previous
* @private * @private
*/ */
destinationsChanged_: function(current, previous) { destinationsChanged_: function() {
if (previous == undefined) { if (!this.initializedDestinations_) {
this.matchingDestinationsCount_ = this.destinations.length; this.matchingDestinationsCount_ = this.destinations.length;
this.initializedDestinations_ = true;
} else { } else {
this.newDestinations_ = true; this.newDestinations_ = true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment