X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fvideos%2F%2Bvideo-watch%2Fcomment%2Fvideo-comment.service.ts;h=0bf7696fe0489bd1cafb4c132a049f1312e69110;hb=169310b288ea4ecfd0a664bc0829b404e1cc7bc2;hp=2fe6cc3e9692ed54a6b78c767534ef084b391571;hpb=4635f59d7c3fea4b97029f10886c62fdf38b2084;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/videos/+video-watch/comment/video-comment.service.ts b/client/src/app/videos/+video-watch/comment/video-comment.service.ts index 2fe6cc3e9..0bf7696fe 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.service.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.service.ts @@ -1,17 +1,20 @@ import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' +import { lineFeedToHtml } from '@app/shared/misc/utils' +import { MarkdownService } from '@app/videos/shared' import 'rxjs/add/operator/catch' import 'rxjs/add/operator/map' import { Observable } from 'rxjs/Observable' import { ResultList } from '../../../../../../shared/models' import { - VideoComment as VideoCommentServerModel, VideoCommentCreate, + VideoComment as VideoCommentServerModel, + VideoCommentCreate, VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' import { environment } from '../../../../environments/environment' import { RestExtractor, RestService } from '../../../shared/rest' import { ComponentPagination } from '../../../shared/rest/component-pagination.model' -import { SortField } from '../../../shared/video/sort-field.type' +import { VideoSortField } from '../../../shared/video/sort-field.type' import { VideoComment } from './video-comment.model' @Injectable() @@ -26,16 +29,18 @@ export class VideoCommentService { addCommentThread (videoId: number | string, comment: VideoCommentCreate) { const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads' + const normalizedComment = lineFeedToHtml(comment, 'text') - return this.authHttp.post(url, comment) + return this.authHttp.post(url, normalizedComment) .map(data => this.extractVideoComment(data['comment'])) .catch(this.restExtractor.handleError) } addCommentReply (videoId: number | string, inReplyToCommentId: number, comment: VideoCommentCreate) { const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comments/' + inReplyToCommentId + const normalizedComment = lineFeedToHtml(comment, 'text') - return this.authHttp.post(url, comment) + return this.authHttp.post(url, normalizedComment) .map(data => this.extractVideoComment(data['comment'])) .catch(this.restExtractor.handleError) } @@ -43,7 +48,7 @@ export class VideoCommentService { getVideoCommentThreads ( videoId: number | string, componentPagination: ComponentPagination, - sort: SortField + sort: VideoSortField ): Observable<{ comments: VideoComment[], totalComments: number}> { const pagination = this.restService.componentPaginationToRestPagination(componentPagination) @@ -66,6 +71,15 @@ export class VideoCommentService { .catch((res) => this.restExtractor.handleError(res)) } + deleteVideoComment (videoId: number | string, commentId: number) { + const url = `${VideoCommentService.BASE_VIDEO_URL + videoId}/comments/${commentId}` + + return this.authHttp + .delete(url) + .map(this.restExtractor.extractDataBool) + .catch((res) => this.restExtractor.handleError(res)) + } + private extractVideoComment (videoComment: VideoCommentServerModel) { return new VideoComment(videoComment) }