]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Automatically jump to the highlighted thread
authorChocobozzz <me@florianbigard.com>
Thu, 14 Jun 2018 09:25:49 +0000 (11:25 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 14 Jun 2018 09:43:19 +0000 (11:43 +0200)
client/src/app/videos/+video-watch/comment/video-comment-add.component.scss
client/src/app/videos/+video-watch/comment/video-comments.component.html
client/src/app/videos/+video-watch/comment/video-comments.component.ts
client/src/app/videos/+video-watch/video-watch.component.ts

index e586880fce11b30debc39d56b74f1a4d9aa603c0..dbce744bf6b3f5a7ec91a625bfbecc03465e0fb4 100644 (file)
@@ -28,7 +28,7 @@ form {
 
 .submit-comment {
   display: flex;
-  justify-content: end;
+  justify-content: flex-end;
 
   button {
     @include peertube-button;
index 7278f7e5792d48f9c181b0ebf82a48c7b58eb17e..8871980e9371e5f3b0c3cf33ad9246b035b121d0 100644 (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"
index 72f66ff09687eac108d04db4efca60cf1685d345..274c32d31b7126e005a985bb7b235f2c03883bb4 100644 (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)
index 498542fff211493ec5f4610869d2fb5f432424b8..a760c03e85b45462cd49b80cf900fd9e8ba95876 100644 (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