From 4c72c1cd411b4ff7ed054b584f184117bae91d5b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 31 May 2019 11:48:28 +0200 Subject: Move concurrently in dev package --- .../videos/+video-watch/video-watch.component.ts | 69 ++++++++++------------ package.json | 2 +- yarn.lock | 2 +- 3 files changed, 34 insertions(+), 39 deletions(-) diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index 55109dc32..2d13f1b58 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -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 } = { + 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')) ] diff --git a/package.json b/package.json index bdc389572..2118c9dcf 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,6 @@ "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", @@ -198,6 +197,7 @@ "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", diff --git a/yarn.lock b/yarn.lock index 6c287a193..4d03b2db7 100644 --- 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== -- cgit v1.2.3