]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Remove avatarUrl from models
authorChocobozzz <me@florianbigard.com>
Wed, 28 Apr 2021 13:59:46 +0000 (15:59 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 28 Apr 2021 13:59:46 +0000 (15:59 +0200)
client/src/app/+videos/+video-watch/video-avatar-channel.component.html
client/src/app/+videos/+video-watch/video-avatar-channel.component.scss
client/src/app/+videos/+video-watch/video-avatar-channel.component.ts
client/src/app/shared/shared-actor-image/actor-avatar.component.ts
client/src/app/shared/shared-main/account/account.model.ts
client/src/app/shared/shared-main/account/actor.model.ts
client/src/app/shared/shared-main/video-channel/video-channel.model.ts
client/src/app/shared/shared-main/video/video.model.ts
client/src/app/shared/shared-video-miniature/video-miniature.component.ts
client/src/app/shared/shared-video-playlist/video-playlist.model.ts

index b8b5d7843c2c974433c5d7a7a22c7e41ee1598f3..5f149cbd1155a3372a0bf3dc452e86ebe06dc550 100644 (file)
@@ -1,21 +1,11 @@
-<div class="wrapper" [ngClass]="'avatar-' + size">
-  <ng-container *ngIf="!isChannelAvatarNull() && !genericChannel">
-    <a [routerLink]="[ '/video-channels', video.byVideoChannel ]" [title]="channelLinkTitle">
-      <img [src]="video.videoChannelAvatarUrl" i18n-alt alt="Channel avatar" class="channel-avatar" />
-    </a>
-
-    <my-actor-avatar [account]="video.account" [title]="accountLinkTitle" [internalHref]="[ '/accounts', video.byAccount ]"></my-actor-avatar>
-</ng-container>
-
-  <ng-container *ngIf="!isChannelAvatarNull() && genericChannel">
-    <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 class="wrapper" [ngClass]="{ 'generic-channel': genericChannel }">
+  <my-actor-avatar
+    class="channel" [channel]="video.channel"
+    [internalHref]="[ '/video-channels', video.byVideoChannel ]" [title]="channelLinkTitle"
+  ></my-actor-avatar>
+
+  <my-actor-avatar
+    class="account" [account]="video.account"
+    [internalHref]="[ '/accounts', video.byAccount ]" [title]="accountLinkTitle">
+  </my-actor-avatar>
 </div>
index 4998e85faa77e120832676298df550e2e0077843..20e32240cdbde340d21bfbc3e5518f1eb3acb59b 100644 (file)
@@ -1,44 +1,42 @@
 @import '_mixins';
 
+@mixin main {
+  @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 {
-  $avatar-size: 35px;
+  @include actor-avatar-size(35px);
 
-  width: $avatar-size;
-  height: $avatar-size;
   position: relative;
   margin-right: 5px;
   margin-bottom: 5px;
 
-  &.avatar-sm {
-    width: 28px;
-    height: 28px;
-    margin-bottom: 3px;
-  }
+  &.generic-channel {
+    .account {
+      @include main();
+    }
 
-  a {
-    @include disable-outline;
+    .channel {
+      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%;
+  &:not(.generic-channel) {
+    .account {
+      @include secondary();
     }
-  }
 
-  a:nth-of-type(2) img {
-    height: 60%;
-    width: 60%;
-    border: 2px solid pvar(--mainBackgroundColor);
-    transform: translateX(15%);
-    position: relative;
-    background-color: pvar(--mainBackgroundColor);
+    .channel {
+      @include main();
+    }
   }
 }
index 0b6e796dff4b132f8b09631caff43f923339c5eb..63edd7badff7a3183bd954c2643b6252b8e8a647 100644 (file)
@@ -10,7 +10,6 @@ export class VideoAvatarChannelComponent implements OnInit {
   @Input() video: Video
   @Input() byAccount: string
 
-  @Input() size: 'md' | 'sm' = 'md'
   @Input() genericChannel: boolean
 
   channelLinkTitle = ''
index 6bb3b65fa31a826835a24285d050ba3e7a353da8..71e020cba14595fa07eee39ab5e4b081fcf9b89b 100644 (file)
@@ -73,7 +73,7 @@ export class ActorAvatarComponent {
 
   get avatarUrl () {
     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 ''
   }
index c90bafa5cf2b7e56dbe41538d0bee43a7dac5cfc..6d9f0ee655eac7dc95b76849e5c73ebeb064d77d 100644 (file)
@@ -24,8 +24,6 @@ export class Account extends Actor implements ServerAccount {
   constructor (hash: ServerAccount) {
     super(hash)
 
-    this.updateComputedAttributes()
-
     this.displayName = hash.displayName
     this.description = hash.description
     this.userId = hash.userId
@@ -40,16 +38,9 @@ export class Account extends Actor implements ServerAccount {
 
   updateAvatar (newAvatar: ActorImage) {
     this.avatar = newAvatar
-
-    this.updateComputedAttributes()
   }
 
   resetAvatar () {
     this.avatar = null
-    this.avatarUrl = null
-  }
-
-  private updateComputedAttributes () {
-    this.avatarUrl = Account.GET_ACTOR_AVATAR_URL(this)
   }
 }
index 4b036341f69e06c02184d664200169828f34950e..6ba0bb09ed7b741c18afc8df7ff437074100f4d7 100644 (file)
@@ -15,7 +15,6 @@ export abstract class Actor implements ServerActor {
   updatedAt: Date | string
 
   avatar: ActorImage
-  avatarUrl: string
 
   isLocal: boolean
 
index 548725e04d4e3004d9b95b3620c70a207a1e4fd2..c40dd53119e1278bf8f008bf15d772d0ddb9a8ec 100644 (file)
@@ -18,7 +18,6 @@ export class VideoChannel extends Actor implements ServerVideoChannel {
 
   ownerAccount?: ServerAccount
   ownerBy?: string
-  ownerAvatarUrl?: string
 
   videosCount?: number
 
@@ -67,7 +66,6 @@ export class VideoChannel extends Actor implements ServerVideoChannel {
     if (hash.ownerAccount) {
       this.ownerAccount = hash.ownerAccount
       this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host)
-      this.ownerAvatarUrl = Account.GET_ACTOR_AVATAR_URL(this.ownerAccount)
     }
 
     this.updateComputedAttributes()
@@ -94,7 +92,6 @@ export class VideoChannel extends Actor implements ServerVideoChannel {
   }
 
   updateComputedAttributes () {
-    this.avatarUrl = VideoChannel.GET_ACTOR_AVATAR_URL(this)
     this.bannerUrl = VideoChannel.GET_ACTOR_BANNER_URL(this)
   }
 }
index 14c507295abe9c45a900f574c8ae82fa6b4dd31f..526d10e32faae2c3c62430f0ca2e37666d18d1ab 100644 (file)
@@ -20,8 +20,6 @@ export class Video implements VideoServerModel {
   byVideoChannel: string
   byAccount: string
 
-  videoChannelAvatarUrl: string
-
   createdAt: Date
   updatedAt: 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.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.licence.label = peertubeTranslate(this.licence.label, translations)
index 8d66aaee2c9a42bc495dd3f83e103896b6ce149e..d74b70d4c19a1e0298f31c2dec0ac52fd5f0665a 100644 (file)
@@ -180,14 +180,6 @@ export class VideoMiniatureComponent implements OnInit {
     return ''
   }
 
-  getAvatarUrl () {
-    if (this.displayOwnerAccount()) {
-      return this.video.account.avatar?.url
-    }
-
-    return this.video.videoChannelAvatarUrl
-  }
-
   loadActions () {
     if (this.displayVideoActions) this.showActions = true
 
index 9bec16d7768190d39b235672e5e3c20a02399c5d..5b6ba9dbf2bc1d089f94d71b2f2c871a2b9ee1e8 100644 (file)
@@ -37,10 +37,8 @@ export class VideoPlaylist implements ServerVideoPlaylist {
   embedUrl: string
 
   ownerBy: string
-  ownerAvatarUrl: string
 
   videoChannelBy?: string
-  videoChannelAvatarUrl?: string
 
   private thumbnailVersion: number
   private originThumbnailUrl: string
@@ -78,12 +76,10 @@ export class VideoPlaylist implements ServerVideoPlaylist {
 
     this.ownerAccount = hash.ownerAccount
     this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host)
-    this.ownerAvatarUrl = Account.GET_ACTOR_AVATAR_URL(this.ownerAccount)
 
     if (hash.videoChannel) {
       this.videoChannel = hash.videoChannel
       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)