| Index: chrome/browser/resources/md_bookmarks/app.js
|
| diff --git a/chrome/browser/resources/md_bookmarks/app.js b/chrome/browser/resources/md_bookmarks/app.js
|
| index 89d6310e5ff74374e88fd8677a637062d7d083da..86650e07e7c49513fa88f65aea51896a416a9d97 100644
|
| --- a/chrome/browser/resources/md_bookmarks/app.js
|
| +++ b/chrome/browser/resources/md_bookmarks/app.js
|
| @@ -5,21 +5,50 @@
|
| Polymer({
|
| is: 'bookmarks-app',
|
|
|
| + behaviors: [
|
| + bookmarks.StoreClient,
|
| + ],
|
| +
|
| properties: {
|
| - selectedId: String,
|
| + searchTerm: {
|
| + type: String,
|
| + observer: 'searchTermChanged_',
|
| + },
|
| + },
|
|
|
| - /** @type {BookmarkTreeNode} */
|
| - rootNode: Object,
|
| + /** @override */
|
| + attached: function() {
|
| + this.observe('searchTerm', function(store) {
|
| + return store.search.term;
|
| + });
|
|
|
| - searchTerm: String,
|
| + chrome.bookmarks.getTree(function(results) {
|
| + var nodeList = bookmarks.util.normalizeNodes(results[0]);
|
| + var initialState = bookmarks.util.createEmptyState();
|
| + initialState.nodes = nodeList;
|
| + initialState.selectedFolder = nodeList['0'].children[0];
|
|
|
| - /** @type {Array<BookmarkTreeNode>} */
|
| - displayedList: Array,
|
| + // TODO(tsergeant): The below ends up slightly duplicating logic from
|
| + // elsewhere. Consider trying to use actions/reducers to simplify this.
|
| + var router = this.$.router;
|
| + if (router.searchTerm) {
|
| + initialState.selectedFolder = null;
|
| + initialState.search.term = router.searchTerm;
|
| + initialState.search.inProgress = true;
|
| + } else if (router.selectedId) {
|
| + initialState.selectedFolder = router.selectedId;
|
| + }
|
| +
|
| + bookmarks.Store.getInstance().init(initialState);
|
| + bookmarks.ApiListener.init();
|
| + }.bind(this));
|
| },
|
|
|
| - /** @override */
|
| - attached: function() {
|
| - /** @type {BookmarksStore} */ (this.$$('bookmarks-store'))
|
| - .initializeStore();
|
| + searchTermChanged_: function() {
|
| + if (this.searchTerm) {
|
| + chrome.bookmarks.search(this.searchTerm, function(results) {
|
| + this.dispatch(bookmarks.actions.setSearchResults(results));
|
| + }.bind(this));
|
| + }
|
| },
|
| });
|
|
|