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

Unified Diff: chrome/browser/resources/md_bookmarks/app.js

Issue 2704983002: MD Bookmarks: Proof-of-concept reimplementation of data storage/binding layer (Closed)
Patch Set: Add doc comments Created 3 years, 10 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_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));
+ }
},
});
« no previous file with comments | « chrome/browser/resources/md_bookmarks/app.html ('k') | chrome/browser/resources/md_bookmarks/compiled_resources2.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698