From ba430d7516bc5b1324b60571ba7594460969b7fb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 18 Dec 2019 15:31:54 +0100 Subject: Lazy load static objects --- .../src/app/videos/+video-edit/video-add.component.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'client/src/app/videos/+video-edit/video-add.component.ts') diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts index 911bc884e..401d8a08f 100644 --- a/client/src/app/videos/+video-edit/video-add.component.ts +++ b/client/src/app/videos/+video-edit/video-add.component.ts @@ -1,28 +1,37 @@ -import { Component, HostListener, ViewChild } from '@angular/core' +import { Component, HostListener, OnInit, ViewChild } from '@angular/core' import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service' import { VideoImportUrlComponent } from '@app/videos/+video-edit/video-add-components/video-import-url.component' import { VideoUploadComponent } from '@app/videos/+video-edit/video-add-components/video-upload.component' import { AuthService, ServerService } from '@app/core' import { VideoImportTorrentComponent } from '@app/videos/+video-edit/video-add-components/video-import-torrent.component' +import { ServerConfig } from '@shared/models' @Component({ selector: 'my-videos-add', templateUrl: './video-add.component.html', styleUrls: [ './video-add.component.scss' ] }) -export class VideoAddComponent implements CanComponentDeactivate { +export class VideoAddComponent implements OnInit, CanComponentDeactivate { @ViewChild('videoUpload', { static: false }) videoUpload: VideoUploadComponent @ViewChild('videoImportUrl', { static: false }) videoImportUrl: VideoImportUrlComponent @ViewChild('videoImportTorrent', { static: false }) videoImportTorrent: VideoImportTorrentComponent secondStepType: 'upload' | 'import-url' | 'import-torrent' videoName: string + serverConfig: ServerConfig constructor ( private auth: AuthService, private serverService: ServerService ) {} + ngOnInit () { + this.serverConfig = this.serverService.getTmpConfig() + + this.serverService.getConfig() + .subscribe(config => this.serverConfig = config) + } + onFirstStepDone (type: 'upload' | 'import-url' | 'import-torrent', videoName: string) { this.secondStepType = type this.videoName = videoName @@ -52,11 +61,11 @@ export class VideoAddComponent implements CanComponentDeactivate { } isVideoImportHttpEnabled () { - return this.serverService.getConfig().import.videos.http.enabled + return this.serverConfig.import.videos.http.enabled } isVideoImportTorrentEnabled () { - return this.serverService.getConfig().import.videos.torrent.enabled + return this.serverConfig.import.videos.torrent.enabled } isInSecondStep () { -- cgit v1.2.3