Verified Commit 2989628b authored by Chocobozzz's avatar Chocobozzz
Browse files

Use HTML config when possible

parent 8e08d415
import { AuthUser } from '@app/core'
import { User } from '@app/core/users/user.model'
import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
import { Account } from '@app/shared/shared-main/account/account.model'
import { Actor } from '@app/shared/shared-main/account/actor.model'
import { VideoChannel } from '@app/shared/shared-main/video-channel/video-channel.model'
import { peertubeTranslate } from '@shared/core-utils/i18n'
import {
ActorImage,
ServerConfig,
HTMLServerConfig,
UserRight,
Video as VideoServerModel,
VideoConstant,
......@@ -163,7 +161,7 @@ export class Video implements VideoServerModel {
this.pluginData = hash.pluginData
}
isVideoNSFWForUser (user: User, serverConfig: ServerConfig) {
isVideoNSFWForUser (user: User, serverConfig: HTMLServerConfig) {
// Video is not NSFW, skip
if (this.nsfw === false) return false
......
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core'
import { AuthService, ConfirmService, Notifier, ServerService, UserService } from '@app/core'
import { Account, DropdownAction } from '@app/shared/shared-main'
import { BulkRemoveCommentsOfBody, ServerConfig, User, UserRight } from '@shared/models'
import { BulkRemoveCommentsOfBody, User, UserRight } from '@shared/models'
import { BlocklistService } from './blocklist.service'
import { BulkService } from './bulk.service'
import { UserBanModalComponent } from './user-ban-modal.component'
......@@ -28,7 +28,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
userActions: DropdownAction<{ user: User, account: Account }>[][] = []
private serverConfig: ServerConfig
requiresEmailVerification = false
constructor (
private authService: AuthService,
......@@ -40,14 +40,9 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
private bulkService: BulkService
) { }
get requiresEmailVerification () {
return this.serverConfig.signup.requiresEmailVerification
}
ngOnInit (): void {
this.serverConfig = this.serverService.getTmpConfig()
ngOnInit () {
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
.subscribe(config => this.requiresEmailVerification = config.signup.requiresEmailVerification)
}
ngOnChanges () {
......
......@@ -2,7 +2,7 @@ import { Subject, Subscription } from 'rxjs'
import { Component, Input, OnDestroy, OnInit } from '@angular/core'
import { AuthService, Notifier, ServerService, UserService } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { ServerConfig, User, UserUpdateMe } from '@shared/models'
import { HTMLServerConfig, User, UserUpdateMe } from '@shared/models'
@Component({
selector: 'my-user-interface-settings',
......@@ -17,7 +17,7 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
formValuesWatcher: Subscription
private serverConfig: ServerConfig
private serverConfig: HTMLServerConfig
constructor (
protected formValidatorService: FormValidatorService,
......@@ -35,9 +35,7 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
}
ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
this.serverConfig = this.serverService.getHTMLConfig()
this.buildForm({
theme: null
......
......@@ -48,9 +48,8 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit,
forkJoin([
this.serverService.getVideoLanguages(),
this.serverService.getConfig(),
this.userInformationLoaded.pipe(first())
]).subscribe(([ languages, config ]) => {
]).subscribe(([ languages ]) => {
const group = this.allLanguagesGroup
this.languageItems = [ { label: $localize`Unknown language`, id: '_unknown', group } ]
......@@ -61,7 +60,8 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit,
? this.user.videoLanguages.map(l => ({ id: l }))
: [ { group } ]
this.defaultNSFWPolicy = config.instance.defaultNSFWPolicy
const serverConfig = this.serverService.getHTMLConfig()
this.defaultNSFWPolicy = serverConfig.instance.defaultNSFWPolicy
this.form.patchValue({
nsfwPolicy: this.user.nsfwPolicy || this.defaultNSFWPolicy,
......
......@@ -25,7 +25,7 @@ import {
import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook'
import { GlobalIconName } from '@app/shared/shared-icons'
import { isLastMonth, isLastWeek, isThisMonth, isToday, isYesterday } from '@shared/core-utils/miscs/date'
import { ServerConfig, UserRight, VideoFilter, VideoSortField } from '@shared/models'
import { HTMLServerConfig, UserRight, VideoFilter, VideoSortField } from '@shared/models'
import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type'
import { Syndication, Video } from '../shared-main'
import { GenericHeaderComponent, VideoListHeaderComponent } from './video-list-header.component'
......@@ -100,7 +100,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
protected onUserLoadedSubject = new ReplaySubject<void>(1)
protected serverConfig: ServerConfig
protected serverConfig: HTMLServerConfig
protected abstract notifier: Notifier
protected abstract authService: AuthService
......@@ -126,9 +126,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte
abstract generateSyndicationList (): void
ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => this.serverConfig = config)
this.serverConfig = this.serverService.getHTMLConfig()
this.groupedDateLabels = {
[GroupDate.UNKNOWN]: null,
......
......@@ -11,7 +11,7 @@ import {
Output
} from '@angular/core'
import { AuthService, ScreenService, ServerService, User } from '@app/core'
import { ServerConfig, VideoPlaylistType, VideoPrivacy, VideoState } from '@shared/models'
import { HTMLServerConfig, VideoPlaylistType, VideoPrivacy, VideoState } from '@shared/models'
import { ActorAvatarSize } from '../shared-actor-image/actor-avatar.component'
import { Video } from '../shared-main'
import { VideoPlaylistService } from '../shared-video-playlist'
......@@ -74,7 +74,7 @@ export class VideoMiniatureComponent implements OnInit {
mute: true
}
showActions = false
serverConfig: ServerConfig
serverConfig: HTMLServerConfig
addToWatchLaterText: string
addedToWatchLaterText: string
......@@ -106,12 +106,8 @@ export class VideoMiniatureComponent implements OnInit {
}
ngOnInit () {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => {
this.serverConfig = config
this.buildVideoLink()
})
this.serverConfig = this.serverService.getHTMLConfig()
this.buildVideoLink()
this.setUpBy()
......
......@@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, In
import { AuthService, Notifier, ServerService } from '@app/core'
import { Video } from '@app/shared/shared-main'
import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'
import { ServerConfig, VideoPlaylistElementType, VideoPlaylistElementUpdate } from '@shared/models'
import { HTMLServerConfig, VideoPlaylistElementType, VideoPlaylistElementUpdate } from '@shared/models'
import { secondsToTime } from '../../../assets/player/utils'
import { VideoPlaylistElement } from './video-playlist-element.model'
import { VideoPlaylist } from './video-playlist.model'
......@@ -37,7 +37,7 @@ export class VideoPlaylistElementMiniatureComponent implements OnInit {
stopTimestamp: number
} = {} as any
private serverConfig: ServerConfig
private serverConfig: HTMLServerConfig
constructor (
private authService: AuthService,
......@@ -48,12 +48,7 @@ export class VideoPlaylistElementMiniatureComponent implements OnInit {
) {}
ngOnInit (): void {
this.serverConfig = this.serverService.getTmpConfig()
this.serverService.getConfig()
.subscribe(config => {
this.serverConfig = config
this.cdr.detectChanges()
})
this.serverConfig = this.serverService.getHTMLConfig()
}
isUnavailable (e: VideoPlaylistElement) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment