}
export function createPostLikeRes(data: PostResponse, post: Post) {
- post.score = data.post.score;
- post.upvotes = data.post.upvotes;
- post.downvotes = data.post.downvotes;
- if (data.post.my_vote !== null) {
- post.my_vote = data.post.my_vote;
+ if (post) {
+ post.score = data.post.score;
+ post.upvotes = data.post.upvotes;
+ post.downvotes = data.post.downvotes;
+ if (data.post.my_vote !== null) {
+ post.my_vote = data.post.my_vote;
+ }
}
}
}
export function editPostRes(data: PostResponse, post: Post) {
- post.url = data.post.url;
- post.name = data.post.name;
- post.nsfw = data.post.nsfw;
+ if (post) {
+ post.url = data.post.url;
+ post.name = data.post.name;
+ post.nsfw = data.post.nsfw;
+ }
}
export function commentsToFlatNodes(