Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/browser/resources/md_history/history_list.js

Issue 2200233003: MD History: Refresh the list when clearing browsing data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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: {
11 type: String, 11 type: String,
12 value: '', 12 value: '',
13 }, 13 },
14 14
15 lastSearchedTerm_: String, 15 lastSearchedTerm_: String,
16 16
17 querying: Boolean, 17 querying: Boolean,
18 18
19 reloadingList_: {
20 type: Boolean,
21 value: false,
22 },
23
19 // An array of history entries in reverse chronological order. 24 // An array of history entries in reverse chronological order.
20 historyData_: Array, 25 historyData_: Array,
21 26
22 resultLoadingDisabled_: { 27 resultLoadingDisabled_: {
23 type: Boolean, 28 type: Boolean,
24 value: false, 29 value: false,
25 }, 30 },
26 }, 31 },
27 32
28 listeners: { 33 listeners: {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 /** 70 /**
66 * Adds the newly updated history results into historyData_. Adds new fields 71 * Adds the newly updated history results into historyData_. Adds new fields
67 * for each result. 72 * for each result.
68 * @param {!Array<!HistoryEntry>} historyResults The new history results. 73 * @param {!Array<!HistoryEntry>} historyResults The new history results.
69 */ 74 */
70 addNewResults: function(historyResults) { 75 addNewResults: function(historyResults) {
71 var results = historyResults.slice(); 76 var results = historyResults.slice();
72 /** @type {IronScrollThresholdElement} */(this.$['scroll-threshold']) 77 /** @type {IronScrollThresholdElement} */(this.$['scroll-threshold'])
73 .clearTriggers(); 78 .clearTriggers();
74 79
75 if (this.lastSearchedTerm_ != this.searchedTerm) { 80 if (this.lastSearchedTerm_ != this.searchedTerm) {
tsergeant 2016/08/08 05:05:12 I'm a concerned about making the logic below more
calamity 2016/08/08 05:55:07 Good idea! This code was written before the increm
76 this.resultLoadingDisabled_ = false; 81 this.resultLoadingDisabled_ = false;
77 if (this.historyData_) 82 if (this.historyData_)
78 this.splice('historyData_', 0, this.historyData_.length); 83 this.splice('historyData_', 0, this.historyData_.length);
79 this.fire('unselect-all'); 84 this.fire('unselect-all');
80 this.lastSearchedTerm_ = this.searchedTerm; 85 this.lastSearchedTerm_ = this.searchedTerm;
81 } 86 }
82 87
83 if (this.historyData_) { 88 if (this.historyData_) {
84 // If we have previously received data, push the new items onto the 89 // Reload the list when browsing data is cleared.
85 // existing array. 90 if (this.reloadingList_) {
86 results.unshift('historyData_'); 91 this.reloadingList_ = false;
87 this.push.apply(this, results); 92 // If we have previously received data, refresh the list unless the user
93 // has any items checked.
94 var selectedItem = this.historyData_.filter(function(item) {
tsergeant 2016/08/08 05:05:12 Chris has a CL in review which makes it much easie
95 return item.selected;
96 });
97 if (selectedItem.length == 0) {
98 this.splice('historyData_', 0, this.historyData_.length);
99 this.set('historyData_', results);
100 }
101 } else {
102 // Infinite scrolling. Push the new items onto the existing array.
103 results.unshift('historyData_');
104 this.push.apply(this, results);
105 }
88 } else { 106 } else {
89 // The first time we receive data, use set() to ensure the iron-list is 107 // The first time we receive data, use set() to ensure the iron-list is
90 // initialized correctly. 108 // initialized correctly.
91 this.set('historyData_', results); 109 this.set('historyData_', results);
92 } 110 }
93 }, 111 },
94 112
113 reloadingList: function() {
114 this.reloadingList_ = true;
115 },
116
95 /** 117 /**
96 * Cycle through each entry in historyData_ and set all items to be 118 * Cycle through each entry in historyData_ and set all items to be
97 * unselected. 119 * unselected.
98 * @param {number} overallItemCount The number of checkboxes selected. 120 * @param {number} overallItemCount The number of checkboxes selected.
99 */ 121 */
100 unselectAllItems: function(overallItemCount) { 122 unselectAllItems: function(overallItemCount) {
101 if (this.historyData_ === undefined) 123 if (this.historyData_ === undefined)
102 return; 124 return;
103 125
104 for (var i = 0; i < this.historyData_.length; i++) { 126 for (var i = 0; i < this.historyData_.length; i++) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 return index == 0; 260 return index == 0;
239 }, 261 },
240 262
241 /** 263 /**
242 * @private 264 * @private
243 */ 265 */
244 notifyListScroll_: function() { 266 notifyListScroll_: function() {
245 this.fire('history-list-scrolled'); 267 this.fire('history-list-scrolled');
246 }, 268 },
247 }); 269 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/history.js ('k') | chrome/browser/resources/md_history/list_container.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698