Skip to content

Commit

Permalink
Hide generic channel display name and avatar on watch view (#2988)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
kimsible and kimsible authored Jul 24, 2020
1 parent e13d7ae commit b40a219
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 13 deletions.
22 changes: 15 additions & 7 deletions client/src/app/+videos/+video-watch/video-watch.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,23 @@ <h1 class="video-info-name">{{ video.name }}</h1>

<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>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ $video-info-margin-left: 44px;
font-weight: 500;
font-size: 90%;
}

a.single-link {
margin-top: 7px;
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions client/src/app/+videos/+video-watch/video-watch.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 24 additions & 6 deletions client/src/app/shared/shared-main/account/avatar.component.html
Original file line number Diff line number Diff line change
@@ -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>
5 changes: 5 additions & 0 deletions client/src/app/shared/shared-main/account/avatar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand All @@ -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
}
}

0 comments on commit b40a219

Please sign in to comment.