aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/video
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-12-18 15:31:54 +0100
committerChocobozzz <me@florianbigard.com>2019-12-18 15:40:59 +0100
commitba430d7516bc5b1324b60571ba7594460969b7fb (patch)
treedf5c6952c82f49a94c0a884bbc97d4a0cbd9f867 /client/src/app/shared/video
parent5dfb7c1dec8222b0bbccac5b56ad46da1438747e (diff)
downloadPeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.gz
PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.zst
PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.zip
Lazy load static objects
Diffstat (limited to 'client/src/app/shared/video')
-rw-r--r--client/src/app/shared/video/abstract-video-list.ts10
-rw-r--r--client/src/app/shared/video/video-miniature.component.ts9
-rw-r--r--client/src/app/shared/video/video.service.ts4
3 files changed, 17 insertions, 6 deletions
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts
index 2926b179b..faeea27d9 100644
--- a/client/src/app/shared/video/abstract-video-list.ts
+++ b/client/src/app/shared/video/abstract-video-list.ts
@@ -13,7 +13,7 @@ import { Notifier, ServerService } from '@app/core'
13import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' 13import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook'
14import { I18n } from '@ngx-translate/i18n-polyfill' 14import { I18n } from '@ngx-translate/i18n-polyfill'
15import { isLastMonth, isLastWeek, isToday, isYesterday } from '@shared/core-utils/miscs/date' 15import { isLastMonth, isLastWeek, isToday, isYesterday } from '@shared/core-utils/miscs/date'
16import { ResultList } from '@shared/models' 16import { ResultList, ServerConfig } from '@shared/models'
17 17
18enum GroupDate { 18enum GroupDate {
19 UNKNOWN = 0, 19 UNKNOWN = 0,
@@ -61,6 +61,8 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor
61 61
62 onDataSubject = new Subject<any[]>() 62 onDataSubject = new Subject<any[]>()
63 63
64 protected serverConfig: ServerConfig
65
64 protected abstract notifier: Notifier 66 protected abstract notifier: Notifier
65 protected abstract authService: AuthService 67 protected abstract authService: AuthService
66 protected abstract route: ActivatedRoute 68 protected abstract route: ActivatedRoute
@@ -85,6 +87,10 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor
85 } 87 }
86 88
87 ngOnInit () { 89 ngOnInit () {
90 this.serverConfig = this.serverService.getTmpConfig()
91 this.serverService.getConfig()
92 .subscribe(config => this.serverConfig = config)
93
88 this.groupedDateLabels = { 94 this.groupedDateLabels = {
89 [GroupDate.UNKNOWN]: null, 95 [GroupDate.UNKNOWN]: null,
90 [GroupDate.TODAY]: this.i18n('Today'), 96 [GroupDate.TODAY]: this.i18n('Today'),
@@ -251,7 +257,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor
251 } 257 }
252 258
253 let path = this.router.url 259 let path = this.router.url
254 if (!path || path === '/') path = this.serverService.getConfig().instance.defaultClientRoute 260 if (!path || path === '/') path = this.serverConfig.instance.defaultClientRoute
255 261
256 this.router.navigate([ path ], { queryParams, replaceUrl: true, queryParamsHandling: 'merge' }) 262 this.router.navigate([ path ], { queryParams, replaceUrl: true, queryParamsHandling: 'merge' })
257 } 263 }
diff --git a/client/src/app/shared/video/video-miniature.component.ts b/client/src/app/shared/video/video-miniature.component.ts
index d5c7dfd9b..9fffc7ddb 100644
--- a/client/src/app/shared/video/video-miniature.component.ts
+++ b/client/src/app/shared/video/video-miniature.component.ts
@@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Inject, Input, LOCALE
2import { User } from '../users' 2import { User } from '../users'
3import { Video } from './video.model' 3import { Video } from './video.model'
4import { ServerService } from '@app/core' 4import { ServerService } from '@app/core'
5import { VideoPrivacy, VideoState } from '../../../../../shared' 5import { ServerConfig, VideoPrivacy, VideoState } from '../../../../../shared'
6import { I18n } from '@ngx-translate/i18n-polyfill' 6import { I18n } from '@ngx-translate/i18n-polyfill'
7import { VideoActionsDisplayType } from '@app/shared/video/video-actions-dropdown.component' 7import { VideoActionsDisplayType } from '@app/shared/video/video-actions-dropdown.component'
8import { ScreenService } from '@app/shared/misc/screen.service' 8import { ScreenService } from '@app/shared/misc/screen.service'
@@ -55,6 +55,7 @@ export class VideoMiniatureComponent implements OnInit {
55 report: true 55 report: true
56 } 56 }
57 showActions = false 57 showActions = false
58 serverConfig: ServerConfig
58 59
59 private ownerDisplayTypeChosen: 'account' | 'videoChannel' 60 private ownerDisplayTypeChosen: 'account' | 'videoChannel'
60 61
@@ -66,10 +67,14 @@ export class VideoMiniatureComponent implements OnInit {
66 ) { } 67 ) { }
67 68
68 get isVideoBlur () { 69 get isVideoBlur () {
69 return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig()) 70 return this.video.isVideoNSFWForUser(this.user, this.serverConfig)
70 } 71 }
71 72
72 ngOnInit () { 73 ngOnInit () {
74 this.serverConfig = this.serverService.getTmpConfig()
75 this.serverService.getConfig()
76 .subscribe(config => this.serverConfig = config)
77
73 this.setUpBy() 78 this.setUpBy()
74 79
75 // We rely on mouseenter to lazy load actions 80 // We rely on mouseenter to lazy load actions
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts
index b0fa55966..9adf46495 100644
--- a/client/src/app/shared/video/video.service.ts
+++ b/client/src/app/shared/video/video.service.ts
@@ -64,7 +64,7 @@ export class VideoService implements VideosProvider {
64 } 64 }
65 65
66 getVideo (options: { videoId: string }): Observable<VideoDetails> { 66 getVideo (options: { videoId: string }): Observable<VideoDetails> {
67 return this.serverService.localeObservable 67 return this.serverService.getServerLocale()
68 .pipe( 68 .pipe(
69 switchMap(translations => { 69 switchMap(translations => {
70 return this.authHttp.get<VideoDetailsServerModel>(VideoService.BASE_VIDEO_URL + options.videoId) 70 return this.authHttp.get<VideoDetailsServerModel>(VideoService.BASE_VIDEO_URL + options.videoId)
@@ -315,7 +315,7 @@ export class VideoService implements VideosProvider {
315 } 315 }
316 316
317 extractVideos (result: ResultList<VideoServerModel>) { 317 extractVideos (result: ResultList<VideoServerModel>) {
318 return this.serverService.localeObservable 318 return this.serverService.getServerLocale()
319 .pipe( 319 .pipe(
320 map(translations => { 320 map(translations => {
321 const videosJson = result.data 321 const videosJson = result.data