Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 /** | 5 /** |
| 6 * @typedef {{querying: boolean, | 6 * @typedef {{querying: boolean, |
| 7 * searchTerm: string, | 7 * searchTerm: string, |
| 8 * results: ?Array<!HistoryEntry>, | 8 * results: ?Array<!HistoryEntry>, |
| 9 * info: ?HistoryQuery, | 9 * info: ?HistoryQuery, |
| 10 * range: HistoryRange, | 10 * range: HistoryRange, |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 // TODO(calamity): Split out readOnly data into a separate property which is | 33 // TODO(calamity): Split out readOnly data into a separate property which is |
| 34 // only set on result return. | 34 // only set on result return. |
| 35 queryState_: { | 35 queryState_: { |
| 36 type: Object, | 36 type: Object, |
| 37 value: function() { | 37 value: function() { |
| 38 return { | 38 return { |
| 39 // A query is initiated by page load. | 39 // A query is initiated by page load. |
| 40 querying: true, | 40 querying: true, |
| 41 searchTerm: '', | 41 searchTerm: '', |
| 42 results: null, | 42 results: null, |
| 43 // Whether the most recent query was incremental. | |
| 44 incremental: false, | |
| 43 info: null, | 45 info: null, |
| 44 range: HistoryRange.ALL_TIME, | 46 range: HistoryRange.ALL_TIME, |
| 45 // TODO(calamity): Make history toolbar buttons change the offset. | 47 // TODO(calamity): Make history toolbar buttons change the offset. |
| 46 groupedOffset: 0, | 48 groupedOffset: 0, |
| 47 sessionList: null, | 49 sessionList: null, |
| 48 }; | 50 }; |
| 49 } | 51 } |
| 50 }, | 52 }, |
| 51 }, | 53 }, |
| 52 | 54 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 168 /** | 170 /** |
| 169 * Queries the history backend for results based on queryState_. | 171 * Queries the history backend for results based on queryState_. |
| 170 * @param {boolean} incremental Whether the new query should continue where | 172 * @param {boolean} incremental Whether the new query should continue where |
| 171 * the previous query stopped. | 173 * the previous query stopped. |
| 172 */ | 174 */ |
| 173 queryHistory: function(incremental) { | 175 queryHistory: function(incremental) { |
| 174 if (this.queryingDisabled_ || this.firstLoad_) | 176 if (this.queryingDisabled_ || this.firstLoad_) |
| 175 return; | 177 return; |
| 176 | 178 |
| 177 this.set('queryState_.querying', true); | 179 this.set('queryState_.querying', true); |
| 180 this.set('queryState_.incremental', incremental); | |
| 178 | 181 |
| 179 var queryState = this.queryState_; | 182 var queryState = this.queryState_; |
| 180 | 183 |
| 181 var lastVisitTime = 0; | 184 var lastVisitTime = 0; |
| 182 if (incremental) { | 185 if (incremental) { |
| 183 var lastVisit = queryState.results.slice(-1)[0]; | 186 var lastVisit = queryState.results.slice(-1)[0]; |
| 184 lastVisitTime = lastVisit ? lastVisit.time : 0; | 187 lastVisitTime = lastVisit ? lastVisit.time : 0; |
| 185 } | 188 } |
| 186 | 189 |
| 187 var maxResults = | 190 var maxResults = |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 204 this.set('queryState_.sessionList', sessionList); | 207 this.set('queryState_.sessionList', sessionList); |
| 205 }, | 208 }, |
| 206 | 209 |
| 207 getSelectedPage: function(selectedPage, range) { | 210 getSelectedPage: function(selectedPage, range) { |
| 208 if (selectedPage == 'history-list' && range != HistoryRange.ALL_TIME) | 211 if (selectedPage == 'history-list' && range != HistoryRange.ALL_TIME) |
| 209 return 'history-grouped-list'; | 212 return 'history-grouped-list'; |
| 210 | 213 |
| 211 return selectedPage; | 214 return selectedPage; |
| 212 }, | 215 }, |
| 213 | 216 |
| 214 syncedTabsSelected_(selectedPage) { | 217 syncedTabsSelected_: function(selectedPage) { |
|
tsergeant
2016/06/06 04:33:16
From the Dept. Of Why Did This Ever Work, apparent
calamity
2016/06/07 04:46:04
Oops + wat
Dan Beam
2016/06/08 01:18:38
http://es6-features.org/#MethodProperties
tsergeant
2016/06/08 02:53:53
Aaaaahhhh, interesting.
| |
| 215 return selectedPage == 'history-synced-device-manager'; | 218 return selectedPage == 'history-synced-device-manager'; |
| 219 }, | |
| 220 | |
| 221 /** | |
| 222 * True if the backend is searching using a new search term. | |
|
calamity
2016/06/07 04:46:04
This is a bit weird. It's not immediately obvious
tsergeant
2016/06/07 06:54:54
Done. As discussed, also renamed the `processing`
| |
| 223 * @param {boolean} querying | |
| 224 * @param {boolean} incremental | |
| 225 * @param {string} searchTerm | |
| 226 * @return {boolean} | |
| 227 * @private | |
| 228 */ | |
| 229 isSearching_: function(querying, incremental, searchTerm) { | |
| 230 return querying && !incremental && searchTerm != ''; | |
| 216 } | 231 } |
| 217 }); | 232 }); |
| OLD | NEW |