Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 Polymer({ | 5 Polymer({ |
| 6 is: 'history-list', | 6 is: 'history-list', |
| 7 | 7 |
| 8 properties: { | 8 properties: { |
| 9 // The search term for the current query. Set when the query returns. | 9 // The search term for the current query. Set when the query returns. |
| 10 searchedTerm: { | 10 searchedTerm: { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 | 74 |
| 75 if (this.lastSearchedTerm_ != this.searchedTerm) { | 75 if (this.lastSearchedTerm_ != this.searchedTerm) { |
| 76 this.resultLoadingDisabled_ = false; | 76 this.resultLoadingDisabled_ = false; |
| 77 if (this.historyData_) | 77 if (this.historyData_) |
| 78 this.splice('historyData_', 0, this.historyData_.length); | 78 this.splice('historyData_', 0, this.historyData_.length); |
| 79 this.fire('unselect-all'); | 79 this.fire('unselect-all'); |
| 80 this.lastSearchedTerm_ = this.searchedTerm; | 80 this.lastSearchedTerm_ = this.searchedTerm; |
| 81 } | 81 } |
| 82 | 82 |
| 83 if (this.historyData_) { | 83 if (this.historyData_) { |
| 84 // If we have previously received data, push the new items onto the | 84 // If we have previously received data, refresh the list unless the user |
| 85 // existing array. | 85 // has any items checked. |
| 86 results.unshift('historyData_'); | 86 var selectedItem = this.historyData_.filter(function(item) { |
| 87 this.push.apply(this, results); | 87 return item.selected; |
|
lshang
2016/08/04 00:17:04
These two lines seem not right.
When there are ne
tsergeant
2016/08/04 01:25:55
These lines support infinite scrolling. When we do
lshang
2016/08/05 03:39:03
Ah, it's for infinite scrolling! Then it makes sen
| |
| 88 }); | |
| 89 if (selectedItem.length == 0) { | |
| 90 this.splice('historyData_', 0, this.historyData_.length); | |
| 91 this.set('historyData_', results); | |
| 92 } | |
| 88 } else { | 93 } else { |
| 89 // The first time we receive data, use set() to ensure the iron-list is | 94 // The first time we receive data, use set() to ensure the iron-list is |
| 90 // initialized correctly. | 95 // initialized correctly. |
| 91 this.set('historyData_', results); | 96 this.set('historyData_', results); |
| 92 } | 97 } |
| 93 }, | 98 }, |
| 94 | 99 |
| 95 /** | 100 /** |
| 96 * Cycle through each entry in historyData_ and set all items to be | 101 * Cycle through each entry in historyData_ and set all items to be |
| 97 * unselected. | 102 * unselected. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 return index == 0; | 243 return index == 0; |
| 239 }, | 244 }, |
| 240 | 245 |
| 241 /** | 246 /** |
| 242 * @private | 247 * @private |
| 243 */ | 248 */ |
| 244 notifyListScroll_: function() { | 249 notifyListScroll_: function() { |
| 245 this.fire('history-list-scrolled'); | 250 this.fire('history-list-scrolled'); |
| 246 }, | 251 }, |
| 247 }); | 252 }); |
| OLD | NEW |