|
@@ -12,3 +12,29 @@ if (Meteor.isClient) {
|
|
|
ReactDOM.render(<App />, document.getElementById('render-target'));
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+Meteor.methods({
|
|
|
+ addTask(text) {
|
|
|
+ // Make sure user is logged before inserting a task.
|
|
|
+ if (!Meteor.userId()) {
|
|
|
+ throw new Meteor.error("not-authorized");
|
|
|
+ }
|
|
|
+
|
|
|
+ Tasks.insert({
|
|
|
+ text: text,
|
|
|
+ createdAt: new Date(),
|
|
|
+ owner: Meteor.userId(),
|
|
|
+ username: Meteor.user().username
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ removeTask(taskId) {
|
|
|
+ // Without checking user ?
|
|
|
+ Tasks.remove(taskId);
|
|
|
+ },
|
|
|
+
|
|
|
+ setChecked(taskId, setChecked) {
|
|
|
+ // Without checking user ?
|
|
|
+ Tasks.update(taskId, { $set: { checked: setChecked }});
|
|
|
+ }
|
|
|
+});
|