aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-17 11:28:11 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-17 11:28:11 +0200
commit154898b0b7bc1af41fc5a94974e338a3590c90f3 (patch)
tree5fb90f66da7587aed53c99ac1884c7acd0c1f7ca /client/src/app/videos
parentdf98563e2104b82b119c00a3cd83cd0dc1242d25 (diff)
downloadPeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.tar.gz
PeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.tar.zst
PeerTube-154898b0b7bc1af41fc5a94974e338a3590c90f3.zip
Share models between server and client
Diffstat (limited to 'client/src/app/videos')
-rw-r--r--client/src/app/videos/shared/rate-type.type.ts1
-rw-r--r--client/src/app/videos/shared/video.service.ts6
-rw-r--r--client/src/app/videos/video-watch/video-watch.component.ts10
3 files changed, 8 insertions, 9 deletions
diff --git a/client/src/app/videos/shared/rate-type.type.ts b/client/src/app/videos/shared/rate-type.type.ts
deleted file mode 100644
index 20eea3ae5..000000000
--- a/client/src/app/videos/shared/rate-type.type.ts
+++ /dev/null
@@ -1 +0,0 @@
1export type RateType = 'like' | 'dislike'
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts
index a4e3d16df..977b82118 100644
--- a/client/src/app/videos/shared/video.service.ts
+++ b/client/src/app/videos/shared/video.service.ts
@@ -6,7 +6,6 @@ import 'rxjs/add/operator/map'
6 6
7import { Search } from '../../shared' 7import { Search } from '../../shared'
8import { SortField } from './sort-field.type' 8import { SortField } from './sort-field.type'
9import { RateType } from './rate-type.type'
10import { AuthService } from '../../core' 9import { AuthService } from '../../core'
11import { 10import {
12 AuthHttp, 11 AuthHttp,
@@ -17,6 +16,7 @@ import {
17 UserService 16 UserService
18} from '../../shared' 17} from '../../shared'
19import { Video } from './video.model' 18import { Video } from './video.model'
19import { VideoRateType } from '../../../../../shared'
20 20
21@Injectable() 21@Injectable()
22export class VideoService { 22export class VideoService {
@@ -145,7 +145,7 @@ export class VideoService {
145 return this.setVideoRate(id, 'dislike') 145 return this.setVideoRate(id, 'dislike')
146 } 146 }
147 147
148 getUserVideoRating (id: string) { 148 getUserVideoRating (id: string): Observable<VideoRateType> {
149 const url = UserService.BASE_USERS_URL + '/me/videos/' + id + '/rating' 149 const url = UserService.BASE_USERS_URL + '/me/videos/' + id + '/rating'
150 150
151 return this.authHttp.get(url) 151 return this.authHttp.get(url)
@@ -159,7 +159,7 @@ export class VideoService {
159 .catch((res) => this.restExtractor.handleError(res)) 159 .catch((res) => this.restExtractor.handleError(res))
160 } 160 }
161 161
162 private setVideoRate (id: string, rateType: RateType) { 162 private setVideoRate (id: string, rateType: VideoRateType) {
163 const url = VideoService.BASE_VIDEO_URL + id + '/rate' 163 const url = VideoService.BASE_VIDEO_URL + id + '/rate'
164 const body = { 164 const body = {
165 rating: rateType 165 rating: rateType
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 4a547f7e4..808e0eda9 100644
--- a/client/src/app/videos/video-watch/video-watch.component.ts
+++ b/client/src/app/videos/video-watch/video-watch.component.ts
@@ -11,15 +11,15 @@ import { AuthService, ConfirmService } from '../../core'
11import { VideoMagnetComponent } from './video-magnet.component' 11import { VideoMagnetComponent } from './video-magnet.component'
12import { VideoShareComponent } from './video-share.component' 12import { VideoShareComponent } from './video-share.component'
13import { VideoReportComponent } from './video-report.component' 13import { VideoReportComponent } from './video-report.component'
14import { RateType, Video, VideoService } from '../shared' 14import { Video, VideoService } from '../shared'
15import { WebTorrentService } from './webtorrent.service' 15import { WebTorrentService } from './webtorrent.service'
16import { UserVideoRateType, VideoRateType, UserVideoRate } from '../../../../../shared'
16 17
17@Component({ 18@Component({
18 selector: 'my-video-watch', 19 selector: 'my-video-watch',
19 templateUrl: './video-watch.component.html', 20 templateUrl: './video-watch.component.html',
20 styleUrls: [ './video-watch.component.scss' ] 21 styleUrls: [ './video-watch.component.scss' ]
21}) 22})
22
23export class VideoWatchComponent implements OnInit, OnDestroy { 23export class VideoWatchComponent implements OnInit, OnDestroy {
24 private static LOADTIME_TOO_LONG = 20000 24 private static LOADTIME_TOO_LONG = 20000
25 25
@@ -34,7 +34,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
34 player: videojs.Player 34 player: videojs.Player
35 playerElement: Element 35 playerElement: Element
36 uploadSpeed: number 36 uploadSpeed: number
37 userRating: RateType = null 37 userRating: UserVideoRateType = null
38 video: Video = null 38 video: Video = null
39 videoNotFound = false 39 videoNotFound = false
40 40
@@ -249,7 +249,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
249 249
250 this.videoService.getUserVideoRating(this.video.id) 250 this.videoService.getUserVideoRating(this.video.id)
251 .subscribe( 251 .subscribe(
252 ratingObject => { 252 (ratingObject: UserVideoRate) => {
253 if (ratingObject) { 253 if (ratingObject) {
254 this.userRating = ratingObject.rating 254 this.userRating = ratingObject.rating
255 } 255 }
@@ -282,7 +282,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
282 ) 282 )
283 } 283 }
284 284
285 private updateVideoRating (oldRating: RateType, newRating: RateType) { 285 private updateVideoRating (oldRating: UserVideoRateType, newRating: VideoRateType) {
286 let likesToIncrement = 0 286 let likesToIncrement = 0
287 let dislikesToIncrement = 0 287 let dislikesToIncrement = 0
288 288