Bug 1131572 - DetailsView.setAvailableViews should be a task, r=jsantell
authorVictor Porof <vporof@mozilla.com>
Tue, 10 Feb 2015 18:36:31 -0500
changeset 228472 7c4d19d34725ac259cadd9b5bcc02c6918c34491
parent 228471 f02908372053c2b33e7225a43bc053790df4b59c
child 228473 6692f4d0a461c515da6eee86d8d86f9799be5b87
push idunknown
push userunknown
push dateunknown
reviewersjsantell
bugs1131572
milestone38.0a1
Bug 1131572 - DetailsView.setAvailableViews should be a task, r=jsantell
browser/devtools/performance/views/details.js
--- a/browser/devtools/performance/views/details.js
+++ b/browser/devtools/performance/views/details.js
@@ -31,17 +31,17 @@ let DetailsView = {
     this._onViewToggle = this._onViewToggle.bind(this);
     this.setAvailableViews = this.setAvailableViews.bind(this);
 
     for (let button of $$("toolbarbutton[data-view]", this.toolbar)) {
       button.addEventListener("command", this._onViewToggle);
     }
 
     yield this.selectView(DEFAULT_DETAILS_SUBVIEW);
-    this.setAvailableViews();
+    yield this.setAvailableViews();
 
     PerformanceController.on(EVENTS.PREF_CHANGED, this.setAvailableViews);
   }),
 
   /**
    * Unbinds events, destroys subviews.
    */
   destroy: Task.async(function *() {
@@ -56,31 +56,31 @@ let DetailsView = {
     PerformanceController.off(EVENTS.PREF_CHANGED, this.setAvailableViews);
   }),
 
   /**
    * Sets the possible views based off of prefs by hiding/showing the
    * buttons that select them and going to default view if currently selected.
    * Called when a preference changes in `devtools.performance.ui.`.
    */
-  setAvailableViews: function () {
+  setAvailableViews: Task.async(function* () {
     for (let [name, { view, pref }] of Iterator(this.components)) {
       if (!pref) {
         continue;
       }
       let value = PerformanceController.getPref(pref);
       $(`toolbarbutton[data-view=${name}]`).hidden = !value;
 
       // If the view is currently selected and not enabled, go back to the
       // default view.
       if (!value && this.isViewSelected(view)) {
-        this.selectView(DEFAULT_DETAILS_SUBVIEW);
+        yield this.selectView(DEFAULT_DETAILS_SUBVIEW);
       }
     }
-  },
+  }),
 
   /**
    * Select one of the DetailView's subviews to be rendered,
    * hiding the others.
    *
    * @param String viewName
    *        Name of the view to be shown.
    */