<div i18n class="title-page title-page-single">
Comments
</div>
- <my-help
+ <my-help
*ngIf="video.commentsEnabled === true" helpType="custom" i18n-customHtml
customHtml="You can either comment on the page of your instance where this video is federated with your PeerTube account, or via any ActivityPub-capable fediverse instance. For instance with Mastodon or Pleroma you can type in the search box <strong>@{{video.account.name}}@{{video.account.host}}</strong> and find back the video. Direct commenting capabilities are being worked on in <a href='https://github.com/Chocobozzz/PeerTube/issues/224'>#224</a>."></my-help>
</div>
[autoLoading]="true"
(nearOfBottom)="onNearOfBottom()"
>
- <div *ngIf="highlightedThread" id="highlighted-comment">
+ <div #commentHighlightBlock id="highlighted-comment">
<my-video-comment
+ *ngIf="highlightedThread"
[comment]="highlightedThread"
[video]="video"
[inReplyToCommentId]="inReplyToCommentId"
-import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'
+import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild, ElementRef } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
import { ConfirmService } from '@app/core'
import { NotificationsService } from 'angular2-notifications'
styleUrls: ['./video-comments.component.scss']
})
export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
+ @ViewChild('commentHighlightBlock') commentHighlightBlock: ElementRef
@Input() video: VideoDetails
@Input() user: User
this.threadComments[commentId] = res
this.threadLoading[commentId] = false
- if (highlightThread) this.highlightedThread = new VideoComment(res.comment)
+ if (highlightThread) {
+ this.highlightedThread = new VideoComment(res.comment)
+
+ // Scroll to the highlighted thread
+ setTimeout(() => {
+ // -60 because of the fixed header
+ console.log(this.commentHighlightBlock.nativeElement.offsetTop)
+ const scrollY = this.commentHighlightBlock.nativeElement.offsetTop - 60
+ window.scroll(0, scrollY)
+ }, 500)
+ }
},
err => this.notificationsService.error(this.i18n('Error'), err.message)
)
this.paramsSub = this.route.params.subscribe(routeParams => {
- if (this.player) {
- this.player.pause()
- }
-
const uuid = routeParams[ 'uuid' ]
// Video did not change
if (this.video && this.video.uuid === uuid) return
+
+ if (this.player) this.player.pause()
+
// Video did change
this.videoService
.getVideo(uuid)
}
private isAutoplay () {
- // True by default
+ // We'll jump to the thread id, so do not play the video
+ if (this.route.snapshot.params['threadId']) return false
+
+ // Otherwise true by default
if (!this.user) return true
// Be sure the autoPlay is set to false