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

Side by Side Diff: chrome/browser/resources/md_bookmarks/reducers.js

Issue 2972963003: MD Bookmarks: Prevent flash of folder contents when changing search term (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/types.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 * @fileoverview Module of functions which produce a new page state in response 6 * @fileoverview Module of functions which produce a new page state in response
7 * to an action. Reducers (in the same sense as Array.prototype.reduce) must be 7 * to an action. Reducers (in the same sense as Array.prototype.reduce) must be
8 * pure functions: they must not modify existing state objects, or make any API 8 * pure functions: they must not modify existing state objects, or make any API
9 * calls. 9 * calls.
10 */ 10 */
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 /** 112 /**
113 * @param {SearchState} search 113 * @param {SearchState} search
114 * @param {Action} action 114 * @param {Action} action
115 * @return {SearchState} 115 * @return {SearchState}
116 */ 116 */
117 SearchState.startSearch = function(search, action) { 117 SearchState.startSearch = function(search, action) {
118 return { 118 return {
119 term: action.term, 119 term: action.term,
120 inProgress: true, 120 inProgress: true,
121 results: [], 121 results: search.results,
122 }; 122 };
123 }; 123 };
124 124
125 /** 125 /**
126 * @param {SearchState} search 126 * @param {SearchState} search
127 * @param {Action} action 127 * @param {Action} action
128 * @return {SearchState} 128 * @return {SearchState}
129 */ 129 */
130 SearchState.finishSearch = function(search, action) { 130 SearchState.finishSearch = function(search, action) {
131 return /** @type {SearchState} */ (Object.assign({}, search, { 131 return /** @type {SearchState} */ (Object.assign({}, search, {
132 inProgress: false, 132 inProgress: false,
133 results: action.results, 133 results: action.results,
134 })); 134 }));
135 }; 135 };
136 136
137 /** @return {SearchState} */ 137 /** @return {SearchState} */
138 SearchState.clearSearch = function() { 138 SearchState.clearSearch = function() {
139 return { 139 return {
140 term: '', 140 term: '',
141 inProgress: false, 141 inProgress: false,
142 results: [], 142 results: null,
143 }; 143 };
144 }; 144 };
145 145
146 /** 146 /**
147 * @param {SearchState} search 147 * @param {SearchState} search
148 * @param {!Set<string>} deletedIds 148 * @param {!Set<string>} deletedIds
149 * @return {SearchState} 149 * @return {SearchState}
150 */ 150 */
151 SearchState.removeDeletedResults = function(search, deletedIds) { 151 SearchState.removeDeletedResults = function(search, deletedIds) {
152 if (!search.results)
153 return search;
154
152 var newResults = []; 155 var newResults = [];
153 search.results.forEach(function(id) { 156 search.results.forEach(function(id) {
154 if (!deletedIds.has(id)) 157 if (!deletedIds.has(id))
155 newResults.push(id); 158 newResults.push(id);
156 }); 159 });
157 return /** @type {SearchState} */ (Object.assign({}, search, { 160 return /** @type {SearchState} */ (Object.assign({}, search, {
158 results: newResults, 161 results: newResults,
159 })); 162 }));
160 }; 163 };
161 164
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 return { 479 return {
477 reduceAction: reduceAction, 480 reduceAction: reduceAction,
478 ClosedFolderState: ClosedFolderState, 481 ClosedFolderState: ClosedFolderState,
479 NodeState: NodeState, 482 NodeState: NodeState,
480 PreferencesState: PreferencesState, 483 PreferencesState: PreferencesState,
481 SearchState: SearchState, 484 SearchState: SearchState,
482 SelectedFolderState: SelectedFolderState, 485 SelectedFolderState: SelectedFolderState,
483 SelectionState: SelectionState, 486 SelectionState: SelectionState,
484 }; 487 };
485 }); 488 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/types.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698