diff options
author | Chocobozzz <me@florianbigard.com> | 2019-12-18 15:31:54 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-12-18 15:40:59 +0100 |
commit | ba430d7516bc5b1324b60571ba7594460969b7fb (patch) | |
tree | df5c6952c82f49a94c0a884bbc97d4a0cbd9f867 /client/src/app/shared/video-playlist | |
parent | 5dfb7c1dec8222b0bbccac5b56ad46da1438747e (diff) | |
download | PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.gz PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.tar.zst PeerTube-ba430d7516bc5b1324b60571ba7594460969b7fb.zip |
Lazy load static objects
Diffstat (limited to 'client/src/app/shared/video-playlist')
-rw-r--r-- | client/src/app/shared/video-playlist/video-playlist-element-miniature.component.ts | 19 | ||||
-rw-r--r-- | client/src/app/shared/video-playlist/video-playlist.service.ts | 6 |
2 files changed, 18 insertions, 7 deletions
diff --git a/client/src/app/shared/video-playlist/video-playlist-element-miniature.component.ts b/client/src/app/shared/video-playlist/video-playlist-element-miniature.component.ts index a8e5a4885..cd592eab0 100644 --- a/client/src/app/shared/video-playlist/video-playlist-element-miniature.component.ts +++ b/client/src/app/shared/video-playlist/video-playlist-element-miniature.component.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, Output, ViewChild } from '@angular/core' | 1 | import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' |
2 | import { Video } from '@app/shared/video/video.model' | 2 | import { Video } from '@app/shared/video/video.model' |
3 | import { VideoPlaylistElementType, VideoPlaylistElementUpdate } from '@shared/models' | 3 | import { ServerConfig, VideoPlaylistElementType, VideoPlaylistElementUpdate } from '@shared/models' |
4 | import { AuthService, ConfirmService, Notifier, ServerService } from '@app/core' | 4 | import { AuthService, ConfirmService, Notifier, ServerService } from '@app/core' |
5 | import { ActivatedRoute } from '@angular/router' | 5 | import { ActivatedRoute } from '@angular/router' |
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | 6 | import { I18n } from '@ngx-translate/i18n-polyfill' |
@@ -17,7 +17,7 @@ import { VideoPlaylistElement } from '@app/shared/video-playlist/video-playlist- | |||
17 | templateUrl: './video-playlist-element-miniature.component.html', | 17 | templateUrl: './video-playlist-element-miniature.component.html', |
18 | changeDetection: ChangeDetectionStrategy.OnPush | 18 | changeDetection: ChangeDetectionStrategy.OnPush |
19 | }) | 19 | }) |
20 | export class VideoPlaylistElementMiniatureComponent { | 20 | export class VideoPlaylistElementMiniatureComponent implements OnInit { |
21 | @ViewChild('moreDropdown', { static: false }) moreDropdown: NgbDropdown | 21 | @ViewChild('moreDropdown', { static: false }) moreDropdown: NgbDropdown |
22 | 22 | ||
23 | @Input() playlist: VideoPlaylist | 23 | @Input() playlist: VideoPlaylist |
@@ -39,6 +39,8 @@ export class VideoPlaylistElementMiniatureComponent { | |||
39 | stopTimestamp: number | 39 | stopTimestamp: number |
40 | } = {} as any | 40 | } = {} as any |
41 | 41 | ||
42 | private serverConfig: ServerConfig | ||
43 | |||
42 | constructor ( | 44 | constructor ( |
43 | private authService: AuthService, | 45 | private authService: AuthService, |
44 | private serverService: ServerService, | 46 | private serverService: ServerService, |
@@ -51,6 +53,15 @@ export class VideoPlaylistElementMiniatureComponent { | |||
51 | private cdr: ChangeDetectorRef | 53 | private cdr: ChangeDetectorRef |
52 | ) {} | 54 | ) {} |
53 | 55 | ||
56 | ngOnInit (): void { | ||
57 | this.serverConfig = this.serverService.getTmpConfig() | ||
58 | this.serverService.getConfig() | ||
59 | .subscribe(config => { | ||
60 | this.serverConfig = config | ||
61 | this.cdr.detectChanges() | ||
62 | }) | ||
63 | } | ||
64 | |||
54 | isUnavailable (e: VideoPlaylistElement) { | 65 | isUnavailable (e: VideoPlaylistElement) { |
55 | return e.type === VideoPlaylistElementType.UNAVAILABLE | 66 | return e.type === VideoPlaylistElementType.UNAVAILABLE |
56 | } | 67 | } |
@@ -80,7 +91,7 @@ export class VideoPlaylistElementMiniatureComponent { | |||
80 | } | 91 | } |
81 | 92 | ||
82 | isVideoBlur (video: Video) { | 93 | isVideoBlur (video: Video) { |
83 | return video.isVideoNSFWForUser(this.authService.getUser(), this.serverService.getConfig()) | 94 | return video.isVideoNSFWForUser(this.authService.getUser(), this.serverConfig) |
84 | } | 95 | } |
85 | 96 | ||
86 | removeFromPlaylist (playlistElement: VideoPlaylistElement) { | 97 | removeFromPlaylist (playlistElement: VideoPlaylistElement) { |
diff --git a/client/src/app/shared/video-playlist/video-playlist.service.ts b/client/src/app/shared/video-playlist/video-playlist.service.ts index 42791af86..2945b4959 100644 --- a/client/src/app/shared/video-playlist/video-playlist.service.ts +++ b/client/src/app/shared/video-playlist/video-playlist.service.ts | |||
@@ -173,7 +173,7 @@ export class VideoPlaylistService { | |||
173 | } | 173 | } |
174 | 174 | ||
175 | extractPlaylists (result: ResultList<VideoPlaylistServerModel>) { | 175 | extractPlaylists (result: ResultList<VideoPlaylistServerModel>) { |
176 | return this.serverService.localeObservable | 176 | return this.serverService.getServerLocale() |
177 | .pipe( | 177 | .pipe( |
178 | map(translations => { | 178 | map(translations => { |
179 | const playlistsJSON = result.data | 179 | const playlistsJSON = result.data |
@@ -190,12 +190,12 @@ export class VideoPlaylistService { | |||
190 | } | 190 | } |
191 | 191 | ||
192 | extractPlaylist (playlist: VideoPlaylistServerModel) { | 192 | extractPlaylist (playlist: VideoPlaylistServerModel) { |
193 | return this.serverService.localeObservable | 193 | return this.serverService.getServerLocale() |
194 | .pipe(map(translations => new VideoPlaylist(playlist, translations))) | 194 | .pipe(map(translations => new VideoPlaylist(playlist, translations))) |
195 | } | 195 | } |
196 | 196 | ||
197 | extractVideoPlaylistElements (result: ResultList<ServerVideoPlaylistElement>) { | 197 | extractVideoPlaylistElements (result: ResultList<ServerVideoPlaylistElement>) { |
198 | return this.serverService.localeObservable | 198 | return this.serverService.getServerLocale() |
199 | .pipe( | 199 | .pipe( |
200 | map(translations => { | 200 | map(translations => { |
201 | const elementsJson = result.data | 201 | const elementsJson = result.data |