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 Polymer({ | 5 Polymer({ |
6 is: 'history-list-container', | 6 is: 'history-list-container', |
7 | 7 |
8 properties: { | 8 properties: { |
9 // The path of the currently selected page. | 9 // The path of the currently selected page. |
10 selectedPage_: String, | 10 selectedPage_: String, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 var queryState = this.queryState; | 59 var queryState = this.queryState; |
60 // Disable querying until the first set of results have been returned. If | 60 // Disable querying until the first set of results have been returned. If |
61 // there is a search, query immediately to support search query params from | 61 // there is a search, query immediately to support search query params from |
62 // the URL. | 62 // the URL. |
63 var noResults = !this.queryResult || this.queryResult.results == null; | 63 var noResults = !this.queryResult || this.queryResult.results == null; |
64 if (queryState.queryingDisabled || | 64 if (queryState.queryingDisabled || |
65 (!this.queryState.searchTerm && noResults)) { | 65 (!this.queryState.searchTerm && noResults)) { |
66 return; | 66 return; |
67 } | 67 } |
68 | 68 |
| 69 // Close any open dialog if a new query is initiated. |
| 70 if (!incremental && this.$.dialog.open) |
| 71 this.$.dialog.close(); |
| 72 |
69 this.set('queryState.querying', true); | 73 this.set('queryState.querying', true); |
70 this.set('queryState.incremental', incremental); | 74 this.set('queryState.incremental', incremental); |
71 | 75 |
72 | |
73 var lastVisitTime = 0; | 76 var lastVisitTime = 0; |
74 if (incremental) { | 77 if (incremental) { |
75 var lastVisit = this.queryResult.results.slice(-1)[0]; | 78 var lastVisit = this.queryResult.results.slice(-1)[0]; |
76 lastVisitTime = lastVisit ? lastVisit.time : 0; | 79 lastVisitTime = lastVisit ? lastVisit.time : 0; |
77 } | 80 } |
78 | 81 |
79 var maxResults = | 82 var maxResults = |
80 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; | 83 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; |
81 chrome.send('queryHistory', [ | 84 chrome.send('queryHistory', [ |
82 queryState.searchTerm, queryState.groupedOffset, queryState.range, | 85 queryState.searchTerm, queryState.groupedOffset, queryState.range, |
(...skipping 24 matching lines...) Expand all Loading... |
107 groupedRangeChanged_: function(range) { | 110 groupedRangeChanged_: function(range) { |
108 this.selectedPage_ = this.queryState.range == HistoryRange.ALL_TIME ? | 111 this.selectedPage_ = this.queryState.range == HistoryRange.ALL_TIME ? |
109 'infinite-list' : 'grouped-list'; | 112 'infinite-list' : 'grouped-list'; |
110 | 113 |
111 this.queryHistory(false); | 114 this.queryHistory(false); |
112 }, | 115 }, |
113 | 116 |
114 /** @private */ | 117 /** @private */ |
115 loadMoreHistory_: function() { this.queryHistory(true); }, | 118 loadMoreHistory_: function() { this.queryHistory(true); }, |
116 | 119 |
117 | |
118 /** | 120 /** |
119 * @param {HistoryQuery} info | 121 * @param {HistoryQuery} info |
120 * @param {!Array<HistoryEntry>} results | 122 * @param {!Array<HistoryEntry>} results |
121 * @private | 123 * @private |
122 */ | 124 */ |
123 initializeResults_: function(info, results) { | 125 initializeResults_: function(info, results) { |
124 if (results.length == 0) | 126 if (results.length == 0) |
125 return; | 127 return; |
126 | 128 |
127 var currentDate = results[0].dateRelativeDay; | 129 var currentDate = results[0].dateRelativeDay; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 .then(function(items) { | 186 .then(function(items) { |
185 this.$['infinite-list'].removeDeletedHistory_(items); | 187 this.$['infinite-list'].removeDeletedHistory_(items); |
186 // This unselect-all is to reset the toolbar when deleting a selected | 188 // This unselect-all is to reset the toolbar when deleting a selected |
187 // item. TODO(tsergeant): Make this automatic based on observing list | 189 // item. TODO(tsergeant): Make this automatic based on observing list |
188 // modifications. | 190 // modifications. |
189 this.fire('unselect-all'); | 191 this.fire('unselect-all'); |
190 }.bind(this)); | 192 }.bind(this)); |
191 menu.closeMenu(); | 193 menu.closeMenu(); |
192 }, | 194 }, |
193 }); | 195 }); |
OLD | NEW |