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

Unified Diff: chrome/browser/resources/md_history/list_container.js

Issue 2590093002: MD History: Move queryState to be managed by history-router (Closed)
Patch Set: Rebase Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/md_history/list_container.js
diff --git a/chrome/browser/resources/md_history/list_container.js b/chrome/browser/resources/md_history/list_container.js
index a166742857a77fa733d64a86fb8f4c5ca5dbc461..b4a28e973e793ff140f107d87e792f0604580bfa 100644
--- a/chrome/browser/resources/md_history/list_container.js
+++ b/chrome/browser/resources/md_history/list_container.js
@@ -13,7 +13,10 @@ Polymer({
},
// The path of the currently selected page.
- selectedPage_: String,
+ selectedPage_: {
+ type: String,
+ computed: 'computeSelectedPage_(groupedRange)',
+ },
// Whether domain-grouped history is enabled.
grouped: Boolean,
@@ -36,12 +39,10 @@ Polymer({
},
observers: [
- 'searchTermChanged_(queryState.searchTerm)',
- 'groupedOffsetChanged_(queryState.groupedOffset)',
+ 'groupedRangeChanged_(queryState.range)',
],
listeners: {
- 'load-more-history': 'loadMoreHistory_',
'open-menu': 'openMenu_',
},
@@ -66,51 +67,13 @@ Polymer({
list.addNewResults(results, this.queryState.incremental, info.finished);
},
- /**
- * Queries the history backend for results based on queryState.
- * @param {boolean} incremental Whether the new query should continue where
- * the previous query stopped.
- */
- queryHistory: function(incremental) {
- var queryState = this.queryState;
- // Disable querying until the first set of results have been returned. If
- // there is a search, query immediately to support search query params from
- // the URL.
- var noResults = !this.queryResult || this.queryResult.results == null;
- if (queryState.queryingDisabled ||
- (!this.queryState.searchTerm && noResults)) {
- return;
- }
-
- // Close any open dialog if a new query is initiated.
- var dialog = this.$.dialog.getIfExists();
- if (!incremental && dialog && dialog.open)
- dialog.close();
-
- this.set('queryState.querying', true);
- this.set('queryState.incremental', incremental);
-
- var lastVisitTime = 0;
- if (incremental) {
- var lastVisit = this.queryResult.results.slice(-1)[0];
- lastVisitTime = lastVisit ? Math.floor(lastVisit.time) : 0;
- }
-
- var maxResults =
- this.groupedRange == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0;
- chrome.send('queryHistory', [
- queryState.searchTerm, queryState.groupedOffset, queryState.range,
- lastVisitTime, maxResults
- ]);
- },
-
historyDeleted: function() {
// Do not reload the list when there are items checked.
if (this.getSelectedItemCount() > 0)
return;
// Reload the list with current search state.
- this.queryHistory(false);
+ this.fire('query-history', false);
},
/** @return {Element} */
@@ -149,44 +112,24 @@ Polymer({
/**
* @param {HistoryRange} range
+ * @return {string}
* @private
*/
- groupedRangeChanged_: function(range, oldRange) {
- this.selectedPage_ =
- range == HistoryRange.ALL_TIME ? 'infinite-list' : 'grouped-list';
-
- if (oldRange == undefined)
- return;
-
- this.set('queryState.groupedOffset', 0);
+ computeSelectedPage_: function(range) {
+ return range == HistoryRange.ALL_TIME ? 'infinite-list' : 'grouped-list';
+ },
+ /**
+ * @param {HistoryRange} range
+ * @private
+ */
+ groupedRangeChanged_: function(range) {
// Reset the results on range change to prevent stale results from being
// processed into the incoming range's UI.
- if (this.queryResult.info) {
+ if (range != HistoryRange.ALL_TIME && this.queryResult.info) {
this.set('queryResult.results', []);
this.historyResult(this.queryResult.info, []);
}
-
- this.queryHistory(false);
- this.fire('history-view-changed');
- },
-
- /** @private */
- searchTermChanged_: function() {
- this.queryHistory(false);
- // TODO(tsergeant): Ignore incremental searches in this metric.
- if (this.queryState.searchTerm)
- md_history.BrowserService.getInstance().recordAction('Search');
- },
-
- /** @private */
- groupedOffsetChanged_: function() {
- this.queryHistory(false);
- },
-
- /** @private */
- loadMoreHistory_: function() {
- this.queryHistory(true);
},
/**
« no previous file with comments | « chrome/browser/resources/md_history/history_list.js ('k') | chrome/browser/resources/md_history/query_manager.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698