X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fvideos%2F%2Bvideo-watch%2Fcomment%2Fvideo-comment-add.component.ts;h=fd85c28f2cb77c1af01ed456fa3ac8149b3e7eee;hb=3866f1a02f73665541468fbadcc3cd2cc459aef2;hp=91af113d243a30d0bea9fb53b20bca2411efa173;hpb=660d11e91e1643927028d2d6870a911f569b34d8;p=github%2FChocobozzz%2FPeerTube.git 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 91af113d2..fd85c28f2 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,6 +1,6 @@ import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' import { Router } from '@angular/router' -import { NotificationsService } from 'angular2-notifications' +import { Notifier } from '@app/core' import { Observable } from 'rxjs' import { VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model' import { FormReactive } from '../../../shared' @@ -29,15 +29,14 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { @Output() commentCreated = new EventEmitter() @ViewChild('visitorModal') visitorModal: NgbModal - @ViewChild('textarea') private textareaElement: ElementRef + @ViewChild('textarea') textareaElement: ElementRef - private addingComment = false - private uri: string + addingComment = false constructor ( protected formValidatorService: FormValidatorService, private videoCommentValidatorsService: VideoCommentValidatorsService, - private notificationsService: NotificationsService, + private notifier: Notifier, private videoCommentService: VideoCommentService, private authService: AuthService, private modalService: NgbModal, @@ -52,8 +51,6 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { text: this.videoCommentValidatorsService.VIDEO_COMMENT_TEXT }) - this.uri = this.router.url - if (this.user) { if (this.focusOnInit === true) { this.textareaElement.nativeElement.focus() @@ -73,13 +70,13 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { } onValidKey () { - this.onValueChanged() + this.check() if (!this.form.valid) return this.formValidated() } - openVisitorModal (event) { + openVisitorModal (event: any) { if (this.user === null) { // we only open it for visitors // fixing ng-bootstrap ModalService and the "Expression Changed After It Has Been Checked" Error event.srcElement.blur() @@ -118,7 +115,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { err => { this.addingComment = false - this.notificationsService.error(this.i18n('Error'), err.text) + this.notifier.error(err.text) } ) } @@ -127,6 +124,10 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { return this.form.value['text'] } + getUrl () { + return window.location.href + } + getAvatarUrl () { if (this.user) return this.user.accountAvatarUrl return window.location.origin + '/client/assets/images/default-avatar.png' @@ -134,7 +135,6 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit { gotoLogin () { this.hideVisitorModal() - this.authService.redirectUrl = this.router.url this.router.navigate([ '/login' ]) }