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

Use HTML config when possible

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