1
0
Fork 0

Automatically jump to the highlighted thread

This commit is contained in:
Chocobozzz 2018-06-14 11:25:49 +02:00
parent 4dae00e68b
commit bf079b7bfd
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 24 additions and 10 deletions

View File

@ -28,7 +28,7 @@ form {
.submit-comment {
display: flex;
justify-content: end;
justify-content: flex-end;
button {
@include peertube-button;

View File

@ -3,7 +3,7 @@
<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>
@ -24,8 +24,9 @@
[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"

View File

@ -1,4 +1,4 @@
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'
@ -19,6 +19,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
styleUrls: ['./video-comments.component.scss']
})
export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
@ViewChild('commentHighlightBlock') commentHighlightBlock: ElementRef
@Input() video: VideoDetails
@Input() user: User
@ -76,7 +77,17 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
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)

View File

@ -101,14 +101,13 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
)
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)
@ -469,7 +468,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
}
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