Move concurrently in dev package
authorChocobozzz <me@florianbigard.com>
Fri, 31 May 2019 09:48:28 +0000 (11:48 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 31 May 2019 09:48:28 +0000 (11:48 +0200)
client/src/app/videos/+video-watch/video-watch.component.ts
package.json
yarn.lock

index 55109dc324d5ae646594610394bf0a4d1ece80a7..2d13f1b58cc82cca10b4d0a66793e62a18a1120a 100644 (file)
@@ -6,7 +6,7 @@ import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
 import { VideoSupportComponent } from '@app/videos/+video-watch/modal/video-support.component'
 import { MetaService } from '@ngx-meta/core'
 import { Notifier, ServerService } from '@app/core'
-import { forkJoin, Subscription } from 'rxjs'
+import { forkJoin, Observable, Subscription } from 'rxjs'
 import { Hotkey, HotkeysService } from 'angular2-hotkeys'
 import { UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '../../../../../shared'
 import { AuthService, ConfirmService } from '../../core'
@@ -135,22 +135,18 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
   setLike () {
     if (this.isUserLoggedIn() === false) return
-    if (this.userRating === 'like') {
-      // Already liked this video
-      this.setRating('none')
-    } else {
-      this.setRating('like')
-    }
+
+    // Already liked this video
+    if (this.userRating === 'like') this.setRating('none')
+    else this.setRating('like')
   }
 
   setDislike () {
     if (this.isUserLoggedIn() === false) return
-    if (this.userRating === 'dislike') {
-      // Already disliked this video
-      this.setRating('none')
-    } else {
-      this.setRating('dislike')
-    }
+
+    // Already disliked this video
+    if (this.userRating === 'dislike') this.setRating('none')
+    else this.setRating('dislike')
   }
 
   showMoreDescription () {
@@ -249,12 +245,15 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
       )
       .subscribe(([ video, captionsResult ]) => {
         const queryParams = this.route.snapshot.queryParams
-        const startTime = queryParams.start
-        const stopTime = queryParams.stop
-        const subtitle = queryParams.subtitle
-        const playerMode = queryParams.mode
 
-        this.onVideoFetched(video, captionsResult.data, { startTime, stopTime, subtitle, playerMode })
+        const urlOptions = {
+          startTime: queryParams.start,
+          stopTime: queryParams.stop,
+          subtitle: queryParams.subtitle,
+          playerMode: queryParams.mode
+        }
+
+        this.onVideoFetched(video, captionsResult.data, urlOptions)
             .catch(err => this.handleError(err))
       })
   }
@@ -279,6 +278,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   private updateVideoDescription (description: string) {
     this.video.description = description
     this.setVideoDescriptionHTML()
+      .catch(err => console.error(err))
   }
 
   private async setVideoDescriptionHTML () {
@@ -385,7 +385,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
         captions: videoCaptions.length !== 0,
         peertubeLink: false,
 
-        videoViewUrl: this.video.privacy.id !== VideoPrivacy.PRIVATE ? this.videoService.getVideoViewUrl(this.video.uuid) : null,
+        videoViewUrl: this.video.privacy.id !== VideoPrivacy.PRIVATE
+          ? this.videoService.getVideoViewUrl(this.video.uuid)
+          : null,
         embedUrl: this.video.embedUrl,
 
         language: this.localeId,
@@ -466,20 +468,13 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   }
 
   private setRating (nextRating: UserVideoRateType) {
-    let method
-    switch (nextRating) {
-      case 'like':
-        method = this.videoService.setVideoLike
-        break
-      case 'dislike':
-        method = this.videoService.setVideoDislike
-        break
-      case 'none':
-        method = this.videoService.unsetVideoLike
-        break
+    const ratingMethods: { [id in UserVideoRateType]: (id: number) => Observable<any> } = {
+      like: this.videoService.setVideoLike,
+      dislike: this.videoService.setVideoDislike,
+      none: this.videoService.unsetVideoLike
     }
 
-    method.call(this.videoService, this.video.id)
+    ratingMethods[nextRating].call(this.videoService, this.video.id)
           .subscribe(
             () => {
               // Update the video like attribute
@@ -556,18 +551,18 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
   private initHotkeys () {
     this.hotkeys = [
-      new Hotkey('shift+l', (event: KeyboardEvent): boolean => {
+      new Hotkey('shift+l', () => {
         this.setLike()
         return false
       }, undefined, this.i18n('Like the video')),
-      new Hotkey('shift+d', (event: KeyboardEvent): boolean => {
+
+      new Hotkey('shift+d', () => {
         this.setDislike()
         return false
       }, undefined, this.i18n('Dislike the video')),
-      new Hotkey('shift+s', (event: KeyboardEvent): boolean => {
-        this.subscribeButton.subscribed ?
-          this.subscribeButton.unsubscribe() :
-          this.subscribeButton.subscribe()
+
+      new Hotkey('shift+s', () => {
+        this.subscribeButton.subscribed ? this.subscribeButton.unsubscribe() : this.subscribeButton.subscribe()
         return false
       }, undefined, this.i18n('Subscribe to the account'))
     ]
index bdc389572ac559045476a5ecfb970525e9171627..2118c9dcfd479a348c82550bcbb609905a9f2b0f 100644 (file)
     "bytes": "^3.0.0",
     "cli-table": "^0.3.1",
     "commander": "^2.13.0",
-    "concurrently": "^4.0.1",
     "config": "^3.0.0",
     "cookie-parser": "^1.4.3",
     "cors": "^2.8.1",
     "chai": "^4.1.1",
     "chai-json-schema": "^1.5.0",
     "chai-xml": "^0.3.2",
+    "concurrently": "^4.1.0",
     "husky": "^1.0.0-rc.4",
     "libxmljs": "0.19.5",
     "lint-staged": "^8.0.4",
index 6c287a193f60c85e702bcce1ba610db65263d90e..4d03b2db7540f2671035e2185750ea415a8dfd97 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -1570,7 +1570,7 @@ concat-stream@^1.4.6, concat-stream@^1.5.2:
     readable-stream "^2.2.2"
     typedarray "^0.0.6"
 
-concurrently@^4.0.1:
+concurrently@^4.1.0:
   version "4.1.0"
   resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-4.1.0.tgz#17fdf067da71210685d9ea554423ef239da30d33"
   integrity sha512-pwzXCE7qtOB346LyO9eFWpkFJVO3JQZ/qU/feGeaAHiX1M3Rw3zgXKc5cZ8vSH5DGygkjzLFDzA/pwoQDkRNGg==