Display avatar in video miniatures (#4823)

* show avatar in video miniatures

closes #4040

* fix: videos for api, include avatars

* add config for display video miniature avatar

* Revert "fix: videos for api, include avatars"

This reverts commit 5520a3eda6.

* video-min: set display avatar to false as default

* remove empty line

* rename display_avatar > display_author_avatar

* fix renaming displayAvatar > displayAuthorAvatar
pull/4846/head
kontrollanten 2022-03-08 13:39:27 +01:00 committed by GitHub
parent fc10ecf167
commit 2c102aac13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 13 deletions

View File

@ -3,7 +3,16 @@ import { fromEvent, Observable, Subject, Subscription } from 'rxjs'
import { debounceTime, switchMap } from 'rxjs/operators' import { debounceTime, switchMap } from 'rxjs/operators'
import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges } from '@angular/core' import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges } from '@angular/core'
import { ActivatedRoute } from '@angular/router' import { ActivatedRoute } from '@angular/router'
import { AuthService, ComponentPaginationLight, Notifier, PeerTubeRouterService, ScreenService, User, UserService } from '@app/core' import {
AuthService,
ComponentPaginationLight,
Notifier,
PeerTubeRouterService,
ScreenService,
ServerService,
User,
UserService
} from '@app/core'
import { GlobalIconName } from '@app/shared/shared-icons' import { GlobalIconName } from '@app/shared/shared-icons'
import { isLastMonth, isLastWeek, isThisMonth, isToday, isYesterday } from '@shared/core-utils' import { isLastMonth, isLastWeek, isThisMonth, isToday, isYesterday } from '@shared/core-utils'
import { ResultList, UserRight, VideoSortField } from '@shared/models' import { ResultList, UserRight, VideoSortField } from '@shared/models'
@ -61,16 +70,7 @@ export class VideosListComponent implements OnInit, OnChanges, OnDestroy {
@Input() hideScopeFilter = false @Input() hideScopeFilter = false
@Input() displayOptions: MiniatureDisplayOptions = { @Input() displayOptions: MiniatureDisplayOptions
date: true,
views: true,
by: true,
avatar: false,
privacyLabel: true,
privacyText: false,
state: false,
blacklistInfo: false
}
@Input() disabled = false @Input() disabled = false
@ -85,6 +85,16 @@ export class VideosListComponent implements OnInit, OnChanges, OnDestroy {
userMiniature: User userMiniature: User
private defaultDisplayOptions: MiniatureDisplayOptions = {
date: true,
views: true,
by: true,
avatar: false,
privacyLabel: true,
privacyText: false,
state: false,
blacklistInfo: false
}
private routeSub: Subscription private routeSub: Subscription
private userSub: Subscription private userSub: Subscription
private resizeSub: Subscription private resizeSub: Subscription
@ -105,7 +115,8 @@ export class VideosListComponent implements OnInit, OnChanges, OnDestroy {
private userService: UserService, private userService: UserService,
private route: ActivatedRoute, private route: ActivatedRoute,
private screenService: ScreenService, private screenService: ScreenService,
private peertubeRouter: PeerTubeRouterService private peertubeRouter: PeerTubeRouterService,
private serverService: ServerService
) { ) {
} }
@ -161,6 +172,14 @@ export class VideosListComponent implements OnInit, OnChanges, OnDestroy {
} }
ngOnChanges (changes: SimpleChanges) { ngOnChanges (changes: SimpleChanges) {
if (changes['displayOptions'] || !this.displayOptions) {
this.displayOptions = {
...this.defaultDisplayOptions,
avatar: this.serverService.getHTMLConfig().client.videos.miniature.displayAuthorAvatar,
...changes['displayOptions']
}
}
if (!this.filters) return if (!this.filters) return
let updated = false let updated = false

View File

@ -624,6 +624,7 @@ client:
miniature: miniature:
# By default PeerTube client displays author username # By default PeerTube client displays author username
prefer_author_display_name: false prefer_author_display_name: false
display_author_avatar: false
menu: menu:
login: login:

View File

@ -632,6 +632,7 @@ client:
miniature: miniature:
# By default PeerTube client displays author username # By default PeerTube client displays author username
prefer_author_display_name: false prefer_author_display_name: false
display_author_avatar: false
menu: menu:
login: login:

View File

@ -33,6 +33,7 @@ function checkMissedConfig () {
'transcoding.resolutions.2160p', 'video_editor.enabled', 'transcoding.resolutions.2160p', 'video_editor.enabled',
'import.videos.http.enabled', 'import.videos.torrent.enabled', 'import.videos.concurrency', 'auto_blacklist.videos.of_users.enabled', 'import.videos.http.enabled', 'import.videos.torrent.enabled', 'import.videos.concurrency', 'auto_blacklist.videos.of_users.enabled',
'trending.videos.interval_days', 'trending.videos.interval_days',
'client.videos.miniature.display_author_avatar',
'client.videos.miniature.prefer_author_display_name', 'client.menu.login.redirect_on_single_external_auth', 'client.videos.miniature.prefer_author_display_name', 'client.menu.login.redirect_on_single_external_auth',
'defaults.publish.download_enabled', 'defaults.publish.comments_enabled', 'defaults.publish.privacy', 'defaults.publish.licence', 'defaults.publish.download_enabled', 'defaults.publish.comments_enabled', 'defaults.publish.privacy', 'defaults.publish.licence',
'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route', 'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route',

View File

@ -62,7 +62,8 @@ const CONFIG = {
CLIENT: { CLIENT: {
VIDEOS: { VIDEOS: {
MINIATURE: { MINIATURE: {
get PREFER_AUTHOR_DISPLAY_NAME () { return config.get<boolean>('client.videos.miniature.prefer_author_display_name') } get PREFER_AUTHOR_DISPLAY_NAME () { return config.get<boolean>('client.videos.miniature.prefer_author_display_name') },
get DISPLAY_AUTHOR_AVATAR () { return config.get<boolean>('client.videos.miniature.display_author_avatar') }
} }
}, },
MENU: { MENU: {

View File

@ -46,6 +46,7 @@ class ServerConfigManager {
client: { client: {
videos: { videos: {
miniature: { miniature: {
displayAuthorAvatar: CONFIG.CLIENT.VIDEOS.MINIATURE.DISPLAY_AUTHOR_AVATAR,
preferAuthorDisplayName: CONFIG.CLIENT.VIDEOS.MINIATURE.PREFER_AUTHOR_DISPLAY_NAME preferAuthorDisplayName: CONFIG.CLIENT.VIDEOS.MINIATURE.PREFER_AUTHOR_DISPLAY_NAME
} }
}, },

View File

@ -38,6 +38,7 @@ export interface ServerConfig {
client: { client: {
videos: { videos: {
miniature: { miniature: {
displayAuthorAvatar: boolean
preferAuthorDisplayName: boolean preferAuthorDisplayName: boolean
} }
} }