-
Notifications
You must be signed in to change notification settings - Fork 8
Pramith/backend routes #61
Changes from 7 commits
01b5517
a4f3150
052f225
9ecb40c
35e51c4
f157c8f
5a607e6
a424b2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ class Course { | |
} | ||
|
||
getInstructorList() { | ||
return this.props.instructorList; | ||
return this.props.instructorList.slice(1, this.props.instructorList.length); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was the purpose of this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rohith said that he and Pawan were going to initialize each list with a dummy string element to make sure Javascript knew that the list was a list of Strings. They wanted the list getters implemented this way to ignore that first dummy string There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh interesting okay I must not have caught that in a previous PR. Honestly that shouldn't be necessary but that could also be a refactor for later. Let's make a comment or something about that in the code to prevent future confusion. |
||
} | ||
|
||
getUUID() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,34 @@ class User { | |
await this.push(); | ||
} | ||
|
||
addLikedPost = async (postId) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a future PR let's write tests for these to make sure that they work |
||
this.props.likedPostList.push(postId); | ||
let post = await getPostById(postId); | ||
post.incrementScore(); | ||
await this.push(); | ||
} | ||
|
||
removeLikedPost = async (postId) => { | ||
this.props.likedPostList.splice(likedPostList.indexOf(postId), 1); | ||
let post = await getPostById(postId); | ||
post.decrementScore(); | ||
await this.push(); | ||
} | ||
|
||
addLikedComment = async (commentId) => { | ||
this.props.likedCommentList.push(commentId); | ||
let comment = await getCommentById(commentId); | ||
comment.incrementScore(); | ||
await this.push(); | ||
} | ||
|
||
removeLikedComment = async (commentId) => { | ||
this.props.likedCommentList.splice(likedCommentList.indexOf(commentId), 1); | ||
let comment = await getCommentById(commentId); | ||
comment.decrementScore(); | ||
await this.push(); | ||
} | ||
|
||
getName() { | ||
return this.props.name; | ||
} | ||
|
@@ -67,6 +95,14 @@ class User { | |
return this.props.followingList.slice(1, this.props.followingList.length); | ||
} | ||
|
||
getLikedPostList() { | ||
return this.props.likedPostList.slice(1, this.props.likedPostList.length); | ||
} | ||
|
||
getLikedCommentList() { | ||
return this.props.likedCommentList.slice(1, this.props.likedCommentList.length); | ||
} | ||
|
||
getIcon() { | ||
return this.props.icon; | ||
} | ||
|
@@ -88,6 +124,9 @@ class User { | |
postList: this.props.postList, | ||
commentList: this.props.commentList, | ||
followingList: this.props.followingList, | ||
// Add this ternary for new fields to prevent old data from crashing | ||
likedPostList: this.props.likedPostList ? this.props.likedPostList : [], | ||
likedCommentList: this.props.likedCommentList ? this.props.likedCommentList : [], | ||
icon: this.props.icon | ||
}); | ||
} | ||
|
@@ -109,6 +148,8 @@ module.exports.pushUserToFirebase = (updateParams) => { | |
postList: ["dummy_post_id"], | ||
commentList: ["dummy_comment_id"], | ||
followingList: ["dummy_post_id"], | ||
likedPostList: ["dummy_post_id"], | ||
likedCommentList: ["dummy_comment_id"], | ||
icon: "anonymous.jpg" | ||
}); | ||
resolve("Everything worked"); | ||
|
@@ -128,7 +169,6 @@ getUserById = async (uuid) => { | |
return new Promise((resolve, reject) => { | ||
ref.once("value", function(snapshot) { | ||
const r = new User(snapshot.val()); | ||
//console.log(r.props.name); | ||
resolve(r); | ||
}, function (errorObject) { | ||
reject(errorObject); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nitpick) Delete the comments