OLD | NEW |
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 Loading... |
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 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 }); |
OLD | NEW |