Skip to content

Commit 6d94639

Browse files
author
Ian Redpath
committed
refactor for date
1 parent 4d66239 commit 6d94639

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

public/project/components/libraries/library.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ export class Library {
190190
.subscribe(resp => {
191191
if (resp.json().comment) {
192192
const comm: any = _.find(this.library.comments, c => { return (<any>c)._id === this.editCommentId })
193-
comm.comment = this.editCommentText
193+
comm.comment = resp.json().comment.comment
194+
comm.date = resp.json().comment.date
194195
this.cancelEditComment()
195196
}
196197
})

public/project/components/movies/movie.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,9 @@ export class Movie {
244244
this.movieService.editCommentForMovie(this.movie._id, this.editCommentId, this.editCommentText)
245245
.subscribe(resp => {
246246
if (resp.json().comment) {
247-
const comm: any = _.find(this.movie.comments, c => { return (<any>c)._id === this.editCommentId })
248-
comm.comment = this.editCommentText
247+
let comm: any = _.find(this.movie.comments, c => { return (<any>c)._id === this.editCommentId })
248+
comm.comment = resp.json().comment.comment
249+
comm.date = resp.json().comment.date
249250
this.cancelEditComment()
250251
}
251252
})
@@ -255,7 +256,7 @@ export class Movie {
255256
this.editCommentId = null
256257
this.editCommentText = ""
257258
}
258-
259+
259260
getCommentDate(datenum: number) {
260261
return new Date(datenum)
261262
}

server/project/models/movie.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export default class LibraryModel {
216216
return deferred.promise
217217
}
218218

219-
editCommentForLibrary(movieId: string, commentId: string, commentText: string) {
219+
editCommentForMovie(movieId: string, commentId: string, commentText: string) {
220220
let deferred = Q.defer()
221221
const date = new Date().getTime()
222222
this.commentModel.findByIdAndUpdate(commentId, { comment: commentText, date }, { new: true }, (err, resp) => {

0 commit comments

Comments
 (0)