From be27ef3b4682c5639039474c39ee0d234d16f482 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 10 Feb 2020 14:25:38 +0100 Subject: Strict templates enabled --- .../+video-watch/comment/video-comment-add.component.ts | 4 ++-- .../+video-watch/comment/video-comment-thread-tree.model.ts | 7 +++++++ .../videos/+video-watch/comment/video-comment.component.ts | 2 +- .../app/videos/+video-watch/comment/video-comment.model.ts | 2 +- .../videos/+video-watch/comment/video-comment.service.ts | 13 +++++++------ .../videos/+video-watch/comment/video-comments.component.ts | 4 ++-- 6 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 client/src/app/videos/+video-watch/comment/video-comment-thread-tree.model.ts (limited to 'client/src/app/videos/+video-watch/comment') 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 1be96ad9e..a8c432653 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 @@ -25,7 +25,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { @Input() parentComments: VideoComment[] @Input() focusOnInit = false - @Output() commentCreated = new EventEmitter() + @Output() commentCreated = new EventEmitter() @Output() cancel = new EventEmitter() @ViewChild('visitorModal', { static: true }) visitorModal: NgbModal @@ -96,7 +96,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { this.addingComment = true const commentCreate: VideoCommentCreate = this.form.value - let obs: Observable + let obs: Observable if (this.parentComment) { obs = this.addCommentReply(commentCreate) diff --git a/client/src/app/videos/+video-watch/comment/video-comment-thread-tree.model.ts b/client/src/app/videos/+video-watch/comment/video-comment-thread-tree.model.ts new file mode 100644 index 000000000..1566d7369 --- /dev/null +++ b/client/src/app/videos/+video-watch/comment/video-comment-thread-tree.model.ts @@ -0,0 +1,7 @@ +import { VideoCommentThreadTree as VideoCommentThreadTreeServerModel } from '../../../../../../shared/models/videos/video-comment.model' +import { VideoComment } from '@app/videos/+video-watch/comment/video-comment.model' + +export class VideoCommentThreadTree implements VideoCommentThreadTreeServerModel { + comment: VideoComment + children: VideoCommentThreadTree[] +} diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.ts index 61f9335d1..f7eca45fd 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts @@ -1,6 +1,5 @@ import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core' import { User, UserRight } from '../../../../../../shared/models/users' -import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' import { AuthService } from '@app/core/auth' import { AccountService } from '@app/shared/account/account.service' import { Video } from '@app/shared/video/video.model' @@ -10,6 +9,7 @@ import { Account } from '@app/shared/account/account.model' import { Notifier } from '@app/core' import { UserService } from '@app/shared' import { Actor } from '@app/shared/actor/actor.model' +import { VideoCommentThreadTree } from '@app/videos/+video-watch/comment/video-comment-thread-tree.model' @Component({ selector: 'my-video-comment', diff --git a/client/src/app/videos/+video-watch/comment/video-comment.model.ts b/client/src/app/videos/+video-watch/comment/video-comment.model.ts index aaeb0ea9c..171fc4acc 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.model.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.model.ts @@ -1,5 +1,5 @@ import { Account as AccountInterface } from '../../../../../../shared/models/actors' -import { VideoComment as VideoCommentServerModel } from '../../../../../../shared/models/videos/video-comment.model' +import { VideoComment as VideoCommentServerModel, VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model' import { Actor } from '@app/shared/actor/actor.model' import { getAbsoluteAPIUrl } from '@app/shared/misc/utils' 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 a81e5236a..0b0715390 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 @@ -7,13 +7,14 @@ import { FeedFormat, ResultList } from '../../../../../../shared/models' import { VideoComment as VideoCommentServerModel, VideoCommentCreate, - VideoCommentThreadTree + VideoCommentThreadTree as VideoCommentThreadTreeServerModel } from '../../../../../../shared/models/videos/video-comment.model' import { environment } from '../../../../environments/environment' import { RestExtractor, RestService } from '../../../shared/rest' import { ComponentPaginationLight } from '../../../shared/rest/component-pagination.model' import { CommentSortField } from '../../../shared/video/sort-field.type' import { VideoComment } from './video-comment.model' +import { VideoCommentThreadTree } from '@app/videos/+video-watch/comment/video-comment-thread-tree.model' @Injectable() export class VideoCommentService { @@ -76,9 +77,9 @@ export class VideoCommentService { const url = `${VideoCommentService.BASE_VIDEO_URL + videoId}/comment-threads/${threadId}` return this.authHttp - .get(url) + .get(url) .pipe( - map(tree => this.extractVideoCommentTree(tree as VideoCommentThreadTree)), + map(tree => this.extractVideoCommentTree(tree)), catchError(err => this.restExtractor.handleError(err)) ) } @@ -138,12 +139,12 @@ export class VideoCommentService { return { data: comments, total: totalComments } } - private extractVideoCommentTree (tree: VideoCommentThreadTree) { - if (!tree) return tree + private extractVideoCommentTree (tree: VideoCommentThreadTreeServerModel) { + if (!tree) return tree as VideoCommentThreadTree tree.comment = new VideoComment(tree.comment) tree.children.forEach(c => this.extractVideoCommentTree(c)) - return tree + return tree as VideoCommentThreadTree } } 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 47720b0ea..750c09c47 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 @@ -1,8 +1,7 @@ -import { Component, ElementRef, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild, Output, EventEmitter } from '@angular/core' +import { Component, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { ConfirmService, Notifier } from '@app/core' import { Subject, Subscription } from 'rxjs' -import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' import { AuthService } from '../../../core/auth' import { ComponentPagination, hasMoreItems } from '../../../shared/rest/component-pagination.model' import { User } from '../../../shared/users' @@ -13,6 +12,7 @@ import { VideoCommentService } from './video-comment.service' import { I18n } from '@ngx-translate/i18n-polyfill' import { Syndication } from '@app/shared/video/syndication.model' import { HooksService } from '@app/core/plugins/hooks.service' +import { VideoCommentThreadTree } from '@app/videos/+video-watch/comment/video-comment-thread-tree.model' @Component({ selector: 'my-video-comments', -- cgit v1.2.3