Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Move concurrently in dev package

Chocobozzz4c72c1cd411b
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 55109dc324..2d13f1b58c 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<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'))
]
diff --git a/package.json b/package.json
index bdc389572a..2118c9dcfd 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 6c287a193f..4d03b2db75 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==