Browse Source

Step 8.4: Replace getMeteorData to filter tasks.

Frederic G. MARAND 8 years ago
parent
commit
85e0619903
1 changed files with 8 additions and 1 deletions
  1. 8 1
      App.jsx

+ 8 - 1
App.jsx

@@ -13,9 +13,16 @@ App = React.createClass({
 
   // Loads items from the Tasks collection and puts them on this.data.tasks.
   getMeteorData() {
+    let query = {};
+
+    if (this.state.hideCompleted) {
+      // If hideCompleted is checked, filter tasks.
+      query = { checked: { $ne: true} };
+    }
     let result = {
-      tasks: Tasks.find({}, {sort: {createdAt: -1}}).fetch()
+      tasks: Tasks.find(query, { sort: { createdAt: -1 }}).fetch()
     };
+
     // Meteor._debug("result", result);
     return result;
   },