diff options
Diffstat (limited to 'client/src/app/videos/+video-watch')
4 files changed, 29 insertions, 22 deletions
diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts index d1ca1968b..b1f446475 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' |
2 | import { FormBuilder, FormGroup } from '@angular/forms' | 2 | import { FormBuilder, FormGroup } from '@angular/forms' |
3 | import { NotificationsService } from 'angular2-notifications' | 3 | import { NotificationsService } from 'angular2-notifications' |
4 | import { Observable } from 'rxjs/Observable' | 4 | import { Observable } from 'rxjs' |
5 | import { VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model' | 5 | import { VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model' |
6 | import { FormReactive } from '../../../shared' | 6 | import { FormReactive } from '../../../shared' |
7 | import { VIDEO_COMMENT_TEXT } from '../../../shared/forms/form-validators/video-comment' | 7 | import { VIDEO_COMMENT_TEXT } from '../../../shared/forms/form-validators/video-comment' |
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 0bf7696fe..5b9a991a0 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,10 +1,8 @@ | |||
1 | import { catchError, map } from 'rxjs/operators' | ||
1 | import { HttpClient, HttpParams } from '@angular/common/http' | 2 | import { HttpClient, HttpParams } from '@angular/common/http' |
2 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
3 | import { lineFeedToHtml } from '@app/shared/misc/utils' | 4 | import { lineFeedToHtml } from '@app/shared/misc/utils' |
4 | import { MarkdownService } from '@app/videos/shared' | 5 | import { Observable } from 'rxjs' |
5 | import 'rxjs/add/operator/catch' | ||
6 | import 'rxjs/add/operator/map' | ||
7 | import { Observable } from 'rxjs/Observable' | ||
8 | import { ResultList } from '../../../../../../shared/models' | 6 | import { ResultList } from '../../../../../../shared/models' |
9 | import { | 7 | import { |
10 | VideoComment as VideoCommentServerModel, | 8 | VideoComment as VideoCommentServerModel, |
@@ -32,8 +30,10 @@ export class VideoCommentService { | |||
32 | const normalizedComment = lineFeedToHtml(comment, 'text') | 30 | const normalizedComment = lineFeedToHtml(comment, 'text') |
33 | 31 | ||
34 | return this.authHttp.post(url, normalizedComment) | 32 | return this.authHttp.post(url, normalizedComment) |
35 | .map(data => this.extractVideoComment(data['comment'])) | 33 | .pipe( |
36 | .catch(this.restExtractor.handleError) | 34 | map(data => this.extractVideoComment(data['comment'])), |
35 | catchError(this.restExtractor.handleError) | ||
36 | ) | ||
37 | } | 37 | } |
38 | 38 | ||
39 | addCommentReply (videoId: number | string, inReplyToCommentId: number, comment: VideoCommentCreate) { | 39 | addCommentReply (videoId: number | string, inReplyToCommentId: number, comment: VideoCommentCreate) { |
@@ -41,8 +41,10 @@ export class VideoCommentService { | |||
41 | const normalizedComment = lineFeedToHtml(comment, 'text') | 41 | const normalizedComment = lineFeedToHtml(comment, 'text') |
42 | 42 | ||
43 | return this.authHttp.post(url, normalizedComment) | 43 | return this.authHttp.post(url, normalizedComment) |
44 | .map(data => this.extractVideoComment(data['comment'])) | 44 | .pipe( |
45 | .catch(this.restExtractor.handleError) | 45 | map(data => this.extractVideoComment(data[ 'comment' ])), |
46 | catchError(this.restExtractor.handleError) | ||
47 | ) | ||
46 | } | 48 | } |
47 | 49 | ||
48 | getVideoCommentThreads ( | 50 | getVideoCommentThreads ( |
@@ -57,27 +59,33 @@ export class VideoCommentService { | |||
57 | 59 | ||
58 | const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads' | 60 | const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads' |
59 | return this.authHttp | 61 | return this.authHttp |
60 | .get(url, { params }) | 62 | .get(url, { params }) |
61 | .map(this.extractVideoComments) | 63 | .pipe( |
62 | .catch((res) => this.restExtractor.handleError(res)) | 64 | map(this.extractVideoComments), |
65 | catchError((res) => this.restExtractor.handleError(res)) | ||
66 | ) | ||
63 | } | 67 | } |
64 | 68 | ||
65 | getVideoThreadComments (videoId: number | string, threadId: number): Observable<VideoCommentThreadTree> { | 69 | getVideoThreadComments (videoId: number | string, threadId: number): Observable<VideoCommentThreadTree> { |
66 | const url = `${VideoCommentService.BASE_VIDEO_URL + videoId}/comment-threads/${threadId}` | 70 | const url = `${VideoCommentService.BASE_VIDEO_URL + videoId}/comment-threads/${threadId}` |
67 | 71 | ||
68 | return this.authHttp | 72 | return this.authHttp |
69 | .get(url) | 73 | .get(url) |
70 | .map(tree => this.extractVideoCommentTree(tree as VideoCommentThreadTree)) | 74 | .pipe( |
71 | .catch((res) => this.restExtractor.handleError(res)) | 75 | map(tree => this.extractVideoCommentTree(tree as VideoCommentThreadTree)), |
76 | catchError((res) => this.restExtractor.handleError(res)) | ||
77 | ) | ||
72 | } | 78 | } |
73 | 79 | ||
74 | deleteVideoComment (videoId: number | string, commentId: number) { | 80 | deleteVideoComment (videoId: number | string, commentId: number) { |
75 | const url = `${VideoCommentService.BASE_VIDEO_URL + videoId}/comments/${commentId}` | 81 | const url = `${VideoCommentService.BASE_VIDEO_URL + videoId}/comments/${commentId}` |
76 | 82 | ||
77 | return this.authHttp | 83 | return this.authHttp |
78 | .delete(url) | 84 | .delete(url) |
79 | .map(this.restExtractor.extractDataBool) | 85 | .pipe( |
80 | .catch((res) => this.restExtractor.handleError(res)) | 86 | map(this.restExtractor.extractDataBool), |
87 | catchError((res) => this.restExtractor.handleError(res)) | ||
88 | ) | ||
81 | } | 89 | } |
82 | 90 | ||
83 | private extractVideoComment (videoComment: VideoCommentServerModel) { | 91 | private extractVideoComment (videoComment: VideoCommentServerModel) { |
@@ -87,7 +95,7 @@ export class VideoCommentService { | |||
87 | private extractVideoComments (result: ResultList<VideoCommentServerModel>) { | 95 | private extractVideoComments (result: ResultList<VideoCommentServerModel>) { |
88 | const videoCommentsJson = result.data | 96 | const videoCommentsJson = result.data |
89 | const totalComments = result.total | 97 | const totalComments = result.total |
90 | const comments = [] | 98 | const comments: VideoComment[] = [] |
91 | 99 | ||
92 | for (const videoCommentJson of videoCommentsJson) { | 100 | for (const videoCommentJson of videoCommentsJson) { |
93 | comments.push(new VideoComment(videoCommentJson)) | 101 | comments.push(new VideoComment(videoCommentJson)) |
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts index a77a6e9f3..34f4a0701 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts | |||
@@ -2,7 +2,7 @@ import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@ | |||
2 | import { ActivatedRoute } from '@angular/router' | 2 | import { ActivatedRoute } from '@angular/router' |
3 | import { ConfirmService } from '@app/core' | 3 | import { ConfirmService } from '@app/core' |
4 | import { NotificationsService } from 'angular2-notifications' | 4 | import { NotificationsService } from 'angular2-notifications' |
5 | import { Subscription } from 'rxjs/Subscription' | 5 | import { Subscription } from 'rxjs' |
6 | import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' | 6 | import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' |
7 | import { AuthService } from '../../../core/auth' | 7 | import { AuthService } from '../../../core/auth' |
8 | import { ComponentPagination } from '../../../shared/rest/component-pagination.model' | 8 | import { ComponentPagination } from '../../../shared/rest/component-pagination.model' |
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index 615b969e5..127ae919d 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -5,7 +5,7 @@ import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' | |||
5 | import { VideoSupportComponent } from '@app/videos/+video-watch/modal/video-support.component' | 5 | import { VideoSupportComponent } from '@app/videos/+video-watch/modal/video-support.component' |
6 | import { MetaService } from '@ngx-meta/core' | 6 | import { MetaService } from '@ngx-meta/core' |
7 | import { NotificationsService } from 'angular2-notifications' | 7 | import { NotificationsService } from 'angular2-notifications' |
8 | import { Subscription } from 'rxjs/Subscription' | 8 | import { Subscription } from 'rxjs' |
9 | import * as videojs from 'video.js' | 9 | import * as videojs from 'video.js' |
10 | import 'videojs-hotkeys' | 10 | import 'videojs-hotkeys' |
11 | import * as WebTorrent from 'webtorrent' | 11 | import * as WebTorrent from 'webtorrent' |
@@ -13,7 +13,6 @@ import { UserVideoRateType, VideoRateType } from '../../../../../shared' | |||
13 | import '../../../assets/player/peertube-videojs-plugin' | 13 | import '../../../assets/player/peertube-videojs-plugin' |
14 | import { AuthService, ConfirmService } from '../../core' | 14 | import { AuthService, ConfirmService } from '../../core' |
15 | import { VideoBlacklistService } from '../../shared' | 15 | import { VideoBlacklistService } from '../../shared' |
16 | import { Account } from '../../shared/account/account.model' | ||
17 | import { VideoDetails } from '../../shared/video/video-details.model' | 16 | import { VideoDetails } from '../../shared/video/video-details.model' |
18 | import { Video } from '../../shared/video/video.model' | 17 | import { Video } from '../../shared/video/video.model' |
19 | import { VideoService } from '../../shared/video/video.service' | 18 | import { VideoService } from '../../shared/video/video.service' |