Remove avatarUrl from models

pull/4027/head
Chocobozzz 2021-04-28 15:59:46 +02:00
parent 746018f6b8
commit 7d026caf68
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
10 changed files with 39 additions and 80 deletions

View File

@ -1,21 +1,11 @@
<div class="wrapper" [ngClass]="'avatar-' + size"> <div class="wrapper" [ngClass]="{ 'generic-channel': genericChannel }">
<ng-container *ngIf="!isChannelAvatarNull() && !genericChannel"> <my-actor-avatar
<a [routerLink]="[ '/video-channels', video.byVideoChannel ]" [title]="channelLinkTitle"> class="channel" [channel]="video.channel"
<img [src]="video.videoChannelAvatarUrl" i18n-alt alt="Channel avatar" class="channel-avatar" /> [internalHref]="[ '/video-channels', video.byVideoChannel ]" [title]="channelLinkTitle"
</a> ></my-actor-avatar>
<my-actor-avatar [account]="video.account" [title]="accountLinkTitle" [internalHref]="[ '/accounts', video.byAccount ]"></my-actor-avatar> <my-actor-avatar
</ng-container> class="account" [account]="video.account"
[internalHref]="[ '/accounts', video.byAccount ]" [title]="accountLinkTitle">
<ng-container *ngIf="!isChannelAvatarNull() && genericChannel"> </my-actor-avatar>
<my-actor-avatar [account]="video.account" [title]="accountLinkTitle" [internalHref]="[ '/accounts', video.byAccount ]"></my-actor-avatar>
<a [routerLink]="[ '/video-channels', video.byVideoChannel ]" [title]="channelLinkTitle">
<img [src]="video.videoChannelAvatarUrl" i18n-alt alt="Channel avatar" class="channel-avatar" />
</a>
</ng-container>
<ng-container *ngIf="isChannelAvatarNull()">
<my-actor-avatar [account]="video.account" [title]="accountLinkTitle" [internalHref]="[ '/accounts', video.byAccount ]"></my-actor-avatar>
</ng-container>
</div> </div>

View File

@ -1,44 +1,42 @@
@import '_mixins'; @import '_mixins';
.wrapper { @mixin main {
$avatar-size: 35px; @include actor-avatar-size(35px);
}
@mixin secondary {
height: 60%;
width: 60%;
position: absolute;
bottom: -5px;
right: -5px;
background-color: rgba(0, 0, 0, 0);
}
.wrapper {
@include actor-avatar-size(35px);
width: $avatar-size;
height: $avatar-size;
position: relative; position: relative;
margin-right: 5px; margin-right: 5px;
margin-bottom: 5px; margin-bottom: 5px;
&.avatar-sm { &.generic-channel {
width: 28px; .account {
height: 28px; @include main();
margin-bottom: 3px; }
}
a { .channel {
@include disable-outline; display: none !important;
}
a img {
height: 100%;
object-fit: cover;
position: absolute;
top:50%;
left:50%;
transform: translate(-50%,-50%);
border-radius: 5px;
&:not(.channel-avatar) {
border-radius: 50%;
} }
} }
a:nth-of-type(2) img { &:not(.generic-channel) {
height: 60%; .account {
width: 60%; @include secondary();
border: 2px solid pvar(--mainBackgroundColor); }
transform: translateX(15%);
position: relative; .channel {
background-color: pvar(--mainBackgroundColor); @include main();
}
} }
} }

View File

@ -10,7 +10,6 @@ export class VideoAvatarChannelComponent implements OnInit {
@Input() video: Video @Input() video: Video
@Input() byAccount: string @Input() byAccount: string
@Input() size: 'md' | 'sm' = 'md'
@Input() genericChannel: boolean @Input() genericChannel: boolean
channelLinkTitle = '' channelLinkTitle = ''

View File

@ -73,7 +73,7 @@ export class ActorAvatarComponent {
get avatarUrl () { get avatarUrl () {
if (this.account) return Account.GET_ACTOR_AVATAR_URL(this.account) if (this.account) return Account.GET_ACTOR_AVATAR_URL(this.account)
if (this.channel) return VideoChannel.GET_ACTOR_AVATAR_URL(this.account) if (this.channel) return VideoChannel.GET_ACTOR_AVATAR_URL(this.channel)
return '' return ''
} }

View File

@ -24,8 +24,6 @@ export class Account extends Actor implements ServerAccount {
constructor (hash: ServerAccount) { constructor (hash: ServerAccount) {
super(hash) super(hash)
this.updateComputedAttributes()
this.displayName = hash.displayName this.displayName = hash.displayName
this.description = hash.description this.description = hash.description
this.userId = hash.userId this.userId = hash.userId
@ -40,16 +38,9 @@ export class Account extends Actor implements ServerAccount {
updateAvatar (newAvatar: ActorImage) { updateAvatar (newAvatar: ActorImage) {
this.avatar = newAvatar this.avatar = newAvatar
this.updateComputedAttributes()
} }
resetAvatar () { resetAvatar () {
this.avatar = null this.avatar = null
this.avatarUrl = null
}
private updateComputedAttributes () {
this.avatarUrl = Account.GET_ACTOR_AVATAR_URL(this)
} }
} }

View File

@ -15,7 +15,6 @@ export abstract class Actor implements ServerActor {
updatedAt: Date | string updatedAt: Date | string
avatar: ActorImage avatar: ActorImage
avatarUrl: string
isLocal: boolean isLocal: boolean

View File

@ -18,7 +18,6 @@ export class VideoChannel extends Actor implements ServerVideoChannel {
ownerAccount?: ServerAccount ownerAccount?: ServerAccount
ownerBy?: string ownerBy?: string
ownerAvatarUrl?: string
videosCount?: number videosCount?: number
@ -67,7 +66,6 @@ export class VideoChannel extends Actor implements ServerVideoChannel {
if (hash.ownerAccount) { if (hash.ownerAccount) {
this.ownerAccount = hash.ownerAccount this.ownerAccount = hash.ownerAccount
this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host) this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host)
this.ownerAvatarUrl = Account.GET_ACTOR_AVATAR_URL(this.ownerAccount)
} }
this.updateComputedAttributes() this.updateComputedAttributes()
@ -94,7 +92,6 @@ export class VideoChannel extends Actor implements ServerVideoChannel {
} }
updateComputedAttributes () { updateComputedAttributes () {
this.avatarUrl = VideoChannel.GET_ACTOR_AVATAR_URL(this)
this.bannerUrl = VideoChannel.GET_ACTOR_BANNER_URL(this) this.bannerUrl = VideoChannel.GET_ACTOR_BANNER_URL(this)
} }
} }

View File

@ -20,8 +20,6 @@ export class Video implements VideoServerModel {
byVideoChannel: string byVideoChannel: string
byAccount: string byAccount: string
videoChannelAvatarUrl: string
createdAt: Date createdAt: Date
updatedAt: Date updatedAt: Date
publishedAt: Date publishedAt: Date
@ -143,7 +141,6 @@ export class Video implements VideoServerModel {
this.byAccount = Actor.CREATE_BY_STRING(hash.account.name, hash.account.host) this.byAccount = Actor.CREATE_BY_STRING(hash.account.name, hash.account.host)
this.byVideoChannel = Actor.CREATE_BY_STRING(hash.channel.name, hash.channel.host) this.byVideoChannel = Actor.CREATE_BY_STRING(hash.channel.name, hash.channel.host)
this.videoChannelAvatarUrl = VideoChannel.GET_ACTOR_AVATAR_URL(this.channel)
this.category.label = peertubeTranslate(this.category.label, translations) this.category.label = peertubeTranslate(this.category.label, translations)
this.licence.label = peertubeTranslate(this.licence.label, translations) this.licence.label = peertubeTranslate(this.licence.label, translations)

View File

@ -180,14 +180,6 @@ export class VideoMiniatureComponent implements OnInit {
return '' return ''
} }
getAvatarUrl () {
if (this.displayOwnerAccount()) {
return this.video.account.avatar?.url
}
return this.video.videoChannelAvatarUrl
}
loadActions () { loadActions () {
if (this.displayVideoActions) this.showActions = true if (this.displayVideoActions) this.showActions = true

View File

@ -37,10 +37,8 @@ export class VideoPlaylist implements ServerVideoPlaylist {
embedUrl: string embedUrl: string
ownerBy: string ownerBy: string
ownerAvatarUrl: string
videoChannelBy?: string videoChannelBy?: string
videoChannelAvatarUrl?: string
private thumbnailVersion: number private thumbnailVersion: number
private originThumbnailUrl: string private originThumbnailUrl: string
@ -78,12 +76,10 @@ export class VideoPlaylist implements ServerVideoPlaylist {
this.ownerAccount = hash.ownerAccount this.ownerAccount = hash.ownerAccount
this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host) this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host)
this.ownerAvatarUrl = Account.GET_ACTOR_AVATAR_URL(this.ownerAccount)
if (hash.videoChannel) { if (hash.videoChannel) {
this.videoChannel = hash.videoChannel this.videoChannel = hash.videoChannel
this.videoChannelBy = Actor.CREATE_BY_STRING(hash.videoChannel.name, hash.videoChannel.host) this.videoChannelBy = Actor.CREATE_BY_STRING(hash.videoChannel.name, hash.videoChannel.host)
this.videoChannelAvatarUrl = VideoChannel.GET_ACTOR_AVATAR_URL(this.videoChannel)
} }
this.privacy.label = peertubeTranslate(this.privacy.label, translations) this.privacy.label = peertubeTranslate(this.privacy.label, translations)