diff options
Diffstat (limited to 'client/src/app/videos')
-rw-r--r-- | client/src/app/videos/+video-watch/video-watch.component.ts | 32 | ||||
-rw-r--r-- | client/src/app/videos/videos-routing.module.ts | 7 |
2 files changed, 20 insertions, 19 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 c71051649..ad572ef58 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import { catchError } from 'rxjs/operators' | ||
1 | import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' | 2 | import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { RedirectService } from '@app/core/routing/redirect.service' | 4 | import { RedirectService } from '@app/core/routing/redirect.service' |
@@ -12,7 +13,7 @@ import * as WebTorrent from 'webtorrent' | |||
12 | import { UserVideoRateType, VideoRateType } from '../../../../../shared' | 13 | import { UserVideoRateType, VideoRateType } from '../../../../../shared' |
13 | import '../../../assets/player/peertube-videojs-plugin' | 14 | import '../../../assets/player/peertube-videojs-plugin' |
14 | import { AuthService, ConfirmService } from '../../core' | 15 | import { AuthService, ConfirmService } from '../../core' |
15 | import { VideoBlacklistService } from '../../shared' | 16 | import { RestExtractor, VideoBlacklistService } from '../../shared' |
16 | import { VideoDetails } from '../../shared/video/video-details.model' | 17 | import { VideoDetails } from '../../shared/video/video-details.model' |
17 | import { Video } from '../../shared/video/video.model' | 18 | import { Video } from '../../shared/video/video.model' |
18 | import { VideoService } from '../../shared/video/video.service' | 19 | import { VideoService } from '../../shared/video/video.service' |
@@ -65,6 +66,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
65 | private metaService: MetaService, | 66 | private metaService: MetaService, |
66 | private authService: AuthService, | 67 | private authService: AuthService, |
67 | private serverService: ServerService, | 68 | private serverService: ServerService, |
69 | private restExtractor: RestExtractor, | ||
68 | private notificationsService: NotificationsService, | 70 | private notificationsService: NotificationsService, |
69 | private markdownService: MarkdownService, | 71 | private markdownService: MarkdownService, |
70 | private zone: NgZone, | 72 | private zone: NgZone, |
@@ -99,21 +101,25 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
99 | } | 101 | } |
100 | 102 | ||
101 | const uuid = routeParams['uuid'] | 103 | const uuid = routeParams['uuid'] |
104 | |||
102 | // Video did not change | 105 | // Video did not change |
103 | if (this.video && this.video.uuid === uuid) return | 106 | if (this.video && this.video.uuid === uuid) return |
104 | // Video did change | 107 | // Video did change |
105 | this.videoService.getVideo(uuid).subscribe( | 108 | this.videoService |
106 | video => { | 109 | .getVideo(uuid) |
107 | const startTime = this.route.snapshot.queryParams.start | 110 | .pipe(catchError(err => this.restExtractor.redirectTo404IfNotFound(err, [ 400, 404 ]))) |
108 | this.onVideoFetched(video, startTime) | 111 | .subscribe( |
109 | .catch(err => this.handleError(err)) | 112 | video => { |
110 | }, | 113 | const startTime = this.route.snapshot.queryParams.start |
111 | 114 | this.onVideoFetched(video, startTime) | |
112 | error => { | 115 | .catch(err => this.handleError(err)) |
113 | this.videoNotFound = true | 116 | }, |
114 | console.error(error) | 117 | |
115 | } | 118 | error => { |
116 | ) | 119 | this.videoNotFound = true |
120 | console.error(error) | ||
121 | } | ||
122 | ) | ||
117 | }) | 123 | }) |
118 | } | 124 | } |
119 | 125 | ||
diff --git a/client/src/app/videos/videos-routing.module.ts b/client/src/app/videos/videos-routing.module.ts index 572f33d5e..66153e033 100644 --- a/client/src/app/videos/videos-routing.module.ts +++ b/client/src/app/videos/videos-routing.module.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { NgModule } from '@angular/core' | 1 | import { NgModule } from '@angular/core' |
2 | import { RouterModule, Routes } from '@angular/router' | 2 | import { RouterModule, Routes, UrlSegment } from '@angular/router' |
3 | import { VideoLocalComponent } from '@app/videos/video-list/video-local.component' | 3 | import { VideoLocalComponent } from '@app/videos/video-list/video-local.component' |
4 | import { MetaGuard } from '@ngx-meta/core' | 4 | import { MetaGuard } from '@ngx-meta/core' |
5 | import { VideoSearchComponent } from './video-list' | 5 | import { VideoSearchComponent } from './video-list' |
@@ -73,11 +73,6 @@ const videosRoutes: Routes = [ | |||
73 | } | 73 | } |
74 | }, | 74 | }, |
75 | { | 75 | { |
76 | path: ':uuid', | ||
77 | pathMatch: 'full', | ||
78 | redirectTo: 'watch/:uuid' | ||
79 | }, | ||
80 | { | ||
81 | path: 'watch/:uuid', | 76 | path: 'watch/:uuid', |
82 | loadChildren: 'app/videos/+video-watch/video-watch.module#VideoWatchModule', | 77 | loadChildren: 'app/videos/+video-watch/video-watch.module#VideoWatchModule', |
83 | data: { | 78 | data: { |