]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Hide generic channel display name and avatar on watch view (#2988)
authorKim <1877318+kimsible@users.noreply.github.com>
Fri, 24 Jul 2020 06:49:59 +0000 (08:49 +0200)
committerGitHub <noreply@github.com>
Fri, 24 Jul 2020 06:49:59 +0000 (08:49 +0200)
* Hide generic channel display name on watch view

* Hide generic channel avatar on watch view

* Add Default username channel as a generic channel display-name

Co-authored-by: kimsible <kimsible@users.noreply.github.com>
client/src/app/+videos/+video-watch/video-watch.component.html
client/src/app/+videos/+video-watch/video-watch.component.scss
client/src/app/+videos/+video-watch/video-watch.component.ts
client/src/app/shared/shared-main/account/avatar.component.html
client/src/app/shared/shared-main/account/avatar.component.ts

index 0447268f0d3a0458a573be085f5855a706690cf5..fb6d0816785f5cb3ae7138409b32907af6d7208d 100644 (file)
 
           <div class="pt-3 border-top video-info-channel d-flex">
             <div class="video-info-channel-left d-flex">
-              <avatar-channel [video]="video"></avatar-channel>
+              <avatar-channel [video]="video" [genericChannel]="isChannelDisplayNameGeneric()"></avatar-channel>
 
               <div class="video-info-channel-left-links ml-1">
-                <a [routerLink]="[ '/video-channels', video.byVideoChannel ]" i18n-title title="Channel page">
-                  {{ video.channel.displayName }}
-                </a>
-                <a [routerLink]="[ '/accounts', video.byAccount ]" i18n-title title="Account page">
-                  <span i18n>By {{ video.byAccount }}</span>
-                </a>
+                <ng-container *ngIf="!isChannelDisplayNameGeneric()">
+                  <a [routerLink]="[ '/video-channels', video.byVideoChannel ]" i18n-title title="Channel page">
+                    {{ video.channel.displayName }}
+                  </a>
+                  <a [routerLink]="[ '/accounts', video.byAccount ]" i18n-title title="Account page">
+                    <span i18n>By {{ video.byAccount }}</span>
+                  </a>
+                </ng-container>
+
+                <ng-container *ngIf="isChannelDisplayNameGeneric()">
+                  <a [routerLink]="[ '/accounts', video.byAccount ]" class="single-link" i18n-title title="Account page">
+                    <span i18n>{{ video.byAccount }}</span>
+                  </a>
+                </ng-container>
               </div>
             </div>
 
index c7f91f4a0374e8fa98ade0be031108050efa7375..00a4b0dee0749fac4d2a156c6473f07cf1d04f15 100644 (file)
@@ -192,6 +192,10 @@ $video-info-margin-left: 44px;
               font-weight: 500;
               font-size: 90%;
             }
+
+            a.single-link {
+              margin-top: 7px;
+            }
           }
         }
 
index 933e6c51fbcd756695e7a22efb8c1b1477f3717e..4341514cd8717daa4802fb6d2ed32d810cdb2d44 100644 (file)
@@ -307,6 +307,15 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     )
   }
 
+  isChannelDisplayNameGeneric () {
+    const genericChannelDisplayName = [
+      `Main ${this.video.channel.ownerAccount.name} channel`,
+      `Default ${this.video.channel.ownerAccount.name} channel`
+    ]
+
+    return genericChannelDisplayName.includes(this.video.channel.displayName)
+  }
+
   private loadVideo (videoId: string) {
     // Video did not change
     if (this.video && this.video.uuid === videoId) return
index 09871fca418b8677bedab47b509e27e095a4f2be..310cc926f51ac84a4c7f050f794da84584c36972 100644 (file)
@@ -1,8 +1,26 @@
 <div class="wrapper" [ngClass]="'avatar-' + size">
-  <a [routerLink]="[ '/video-channels', video.byVideoChannel ]" [title]="channelLinkTitle">
-    <img [src]="video.videoChannelAvatarUrl" i18n-alt alt="Channel avatar" />
-  </a>
-  <a [routerLink]="[ '/accounts', video.byAccount ]" [title]="accountLinkTitle">
-    <img [src]="video.accountAvatarUrl" i18n-alt alt="Account avatar" />
-  </a>
+  <ng-container *ngIf="!isChannelAvatarNull() && !genericChannel">
+    <a [routerLink]="[ '/video-channels', video.byVideoChannel ]" [title]="channelLinkTitle">
+      <img [src]="video.videoChannelAvatarUrl" i18n-alt alt="Channel avatar" />
+    </a>
+    <a [routerLink]="[ '/accounts', video.byAccount ]" [title]="accountLinkTitle">
+      <img [src]="video.accountAvatarUrl" i18n-alt alt="Account avatar" />
+    </a>
+  </ng-container>
+
+  <ng-container *ngIf="!isChannelAvatarNull() && genericChannel">
+    <a [routerLink]="[ '/accounts', video.byAccount ]" [title]="accountLinkTitle">
+      <img [src]="video.accountAvatarUrl" i18n-alt alt="Account avatar" />
+    </a>
+
+    <a [routerLink]="[ '/video-channels', video.byVideoChannel ]" [title]="channelLinkTitle">
+      <img [src]="video.videoChannelAvatarUrl" i18n-alt alt="Channel avatar" />
+    </a>
+  </ng-container>
+
+  <ng-container *ngIf="isChannelAvatarNull()">
+    <a [routerLink]="[ '/accounts', video.byAccount ]" [title]="accountLinkTitle">
+      <img [src]="video.accountAvatarUrl" i18n-alt alt="Account avatar" />
+    </a>
+  </ng-container>
 </div>
index 31f39c20013336d0906d2f3a31351192d7b94aaa..73c145ef9e5cfc5ea524101c42b65586f9a2fd7c 100644 (file)
@@ -10,6 +10,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
 export class AvatarComponent implements OnInit {
   @Input() video: Video
   @Input() size: 'md' | 'sm' = 'md'
+  @Input() genericChannel: boolean
 
   channelLinkTitle = ''
   accountLinkTitle = ''
@@ -28,4 +29,8 @@ export class AvatarComponent implements OnInit {
       { name: this.video.account.name, handle: this.video.byAccount }
     )
   }
+
+  isChannelAvatarNull () {
+    return this.video.channel.avatar === null
+  }
 }