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

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

Issue 2746363013: [MD Bookmarks] Add a drag and drop indicator to bookmarks. (Closed)
Patch Set: address comments Created 3 years, 8 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 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 SelectedFolderState.isAncestorOf( 250 SelectedFolderState.isAncestorOf(
251 nodes, action.id, selectedFolder)) { 251 nodes, action.id, selectedFolder)) {
252 return action.id; 252 return action.id;
253 } 253 }
254 return selectedFolder; 254 return selectedFolder;
255 case 'finish-search': 255 case 'finish-search':
256 return null; 256 return null;
257 case 'clear-search': 257 case 'clear-search':
258 // TODO(tsergeant): Return to the folder that was selected before the 258 // TODO(tsergeant): Return to the folder that was selected before the
259 // search. 259 // search.
260 return nodes['0'].children[0]; 260 return nodes[bookmarks.util.ROOT_NODE_ID].children[0];
261 default: 261 default:
262 return selectedFolder; 262 return selectedFolder;
263 } 263 }
264 }; 264 };
265 265
266 var ClosedFolderState = {}; 266 var ClosedFolderState = {};
267 267
268 /** 268 /**
269 * @param {ClosedFolderState} closedFolders 269 * @param {ClosedFolderState} closedFolders
270 * @param {string|undefined} id 270 * @param {string|undefined} id
271 * @param {NodeList} nodes 271 * @param {NodeList} nodes
272 * @return {ClosedFolderState} 272 * @return {ClosedFolderState}
273 */ 273 */
274 ClosedFolderState.openFolderAndAncestors = function( 274 ClosedFolderState.openFolderAndAncestors = function(
275 closedFolders, id, nodes) { 275 closedFolders, id, nodes) {
276 var modifications = {}; 276 var modifications = {};
277 var currentId = id; 277 var currentId = id;
278 while (currentId) { 278 while (currentId) {
279 if (closedFolders[currentId]) { 279 if (closedFolders[currentId])
280 modifications[currentId] = false; 280 modifications[currentId] = false;
281 } 281
282 currentId = nodes[currentId].parentId; 282 currentId = nodes[currentId].parentId;
283 } 283 }
284 284
285 return Object.assign({}, closedFolders, modifications); 285 return Object.assign({}, closedFolders, modifications);
286 }; 286 };
287 287
288 /** 288 /**
289 * @param {ClosedFolderState} closedFolders 289 * @param {ClosedFolderState} closedFolders
290 * @param {Action} action 290 * @param {Action} action
291 * @return {ClosedFolderState} 291 * @return {ClosedFolderState}
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 344
345 return { 345 return {
346 reduceAction: reduceAction, 346 reduceAction: reduceAction,
347 ClosedFolderState: ClosedFolderState, 347 ClosedFolderState: ClosedFolderState,
348 NodeState: NodeState, 348 NodeState: NodeState,
349 SearchState: SearchState, 349 SearchState: SearchState,
350 SelectedFolderState: SelectedFolderState, 350 SelectedFolderState: SelectedFolderState,
351 SelectionState: SelectionState, 351 SelectionState: SelectionState,
352 }; 352 };
353 }); 353 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698