mirror of https://github.com/Chocobozzz/PeerTube
Don't always use a link for account avatar
parent
5b23d4e0f8
commit
126a6352ec
|
@ -23,8 +23,8 @@
|
|||
<div class="section-label" i18n>OWNER ACCOUNT</div>
|
||||
|
||||
<div class="avatar-row">
|
||||
<my-account-avatar [account]="videoChannel.ownerAccount" size="120"></my-account-avatar>
|
||||
|
||||
<my-account-avatar [account]="videoChannel.ownerAccount" [internalHref]="getAccountUrl()" size="120"></my-account-avatar>
|
||||
|
||||
<div class="actor-info">
|
||||
<h4>
|
||||
<a [routerLink]="getAccountUrl()" title="View account" i18n-title>{{ videoChannel.ownerAccount.displayName }}</a>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div *ngIf="isCommentDisplayed()" class="root-comment">
|
||||
<div class="left">
|
||||
<my-account-avatar *ngIf="!comment.isDeleted" [account]="comment.account"></my-account-avatar>
|
||||
<my-account-avatar *ngIf="!comment.isDeleted" [href]="comment.account.url" [account]="comment.account"></my-account-avatar>
|
||||
<div class="vertical-border"></div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
<img [src]="video.videoChannelAvatarUrl" i18n-alt alt="Channel avatar" class="channel-avatar" />
|
||||
</a>
|
||||
|
||||
<my-account-avatar [account]="video.account"></my-account-avatar>
|
||||
<my-account-avatar [account]="video.account" [title]="accountLinkTitle" [internalHref]="[ '/accounts', video.byAccount ]"></my-account-avatar>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="!isChannelAvatarNull() && genericChannel">
|
||||
<my-account-avatar [account]="video.account"></my-account-avatar>
|
||||
<my-account-avatar [account]="video.account" [title]="accountLinkTitle" [internalHref]="[ '/accounts', video.byAccount ]"></my-account-avatar>
|
||||
|
||||
<a [routerLink]="[ '/video-channels', video.byVideoChannel ]" [title]="channelLinkTitle">
|
||||
<img [src]="video.videoChannelAvatarUrl" i18n-alt alt="Channel avatar" class="channel-avatar" />
|
||||
|
@ -16,6 +16,6 @@
|
|||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="isChannelAvatarNull()">
|
||||
<my-account-avatar [account]="video.account"></my-account-avatar>
|
||||
<my-account-avatar [account]="video.account" [title]="accountLinkTitle" [internalHref]="[ '/accounts', video.byAccount ]"></my-account-avatar>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
<a *ngIf="account" [href]="href" target="_blank" rel="noopener noreferrer" [title]="title">
|
||||
<img
|
||||
[class]="class"
|
||||
[src]="avatarUrl"
|
||||
i18n-alt
|
||||
alt="Account avatar"
|
||||
/>
|
||||
<ng-template #img>
|
||||
<img [class]="class" [src]="avatarUrl" i18n-alt alt="Account avatar" />
|
||||
</ng-template>
|
||||
|
||||
<a *ngIf="account && href" [href]="href" target="_blank" rel="noopener noreferrer" [title]="title">
|
||||
<ng-template *ngTemplateOutlet="img"></ng-template>
|
||||
</a>
|
||||
|
||||
<a *ngIf="account && internalHref" [routerLink]="internalHref" [title]="title">
|
||||
<ng-template *ngTemplateOutlet="img"></ng-template>
|
||||
</a>
|
||||
|
||||
<ng-container *ngIf="!account || (!href && !internalHref)">
|
||||
<ng-template *ngTemplateOutlet="img"></ng-template>
|
||||
</ng-container>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { Component, Input } from '@angular/core'
|
||||
import { Account as AccountInterface } from '@shared/models'
|
||||
import { Account } from '../shared-main/account/account.model'
|
||||
|
||||
@Component({
|
||||
|
@ -8,21 +7,23 @@ import { Account } from '../shared-main/account/account.model'
|
|||
templateUrl: './account-avatar.component.html'
|
||||
})
|
||||
export class AccountAvatarComponent {
|
||||
_href: string
|
||||
_title: string
|
||||
|
||||
@Input() account: { name: string, avatar?: { url?: string }, url: string }
|
||||
@Input() size = '36'
|
||||
@Input() set href (value) {
|
||||
this._href = value
|
||||
@Input() account: {
|
||||
name: string
|
||||
avatar?: { url?: string, path: string }
|
||||
url: string
|
||||
}
|
||||
@Input() size: '25' | '34' | '36' | '40' | '120' = '36'
|
||||
|
||||
// Use an external link
|
||||
@Input() href: string
|
||||
// Use routerLink
|
||||
@Input() internalHref: string | string[]
|
||||
|
||||
@Input() set title (value) {
|
||||
this._title = value
|
||||
}
|
||||
|
||||
get href () {
|
||||
return this._href || this.account?.url
|
||||
}
|
||||
private _title: string
|
||||
|
||||
get title () {
|
||||
return this._title || $localize`${this.account.name} (account page)`
|
||||
|
@ -33,6 +34,6 @@ export class AccountAvatarComponent {
|
|||
}
|
||||
|
||||
get avatarUrl () {
|
||||
return this.account?.avatar ? this.account.avatar.url : Account.GET_DEFAULT_AVATAR_URL()
|
||||
return Account.GET_ACTOR_AVATAR_URL(this.account)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Account as ServerAccount, ActorImage } from '@shared/models'
|
||||
import { Account as ServerAccount, Actor as ServerActor, ActorImage } from '@shared/models'
|
||||
import { Actor } from './actor.model'
|
||||
|
||||
export class Account extends Actor implements ServerAccount {
|
||||
|
@ -13,7 +13,7 @@ export class Account extends Actor implements ServerAccount {
|
|||
|
||||
userId?: number
|
||||
|
||||
static GET_ACTOR_AVATAR_URL (actor: object) {
|
||||
static GET_ACTOR_AVATAR_URL (actor: { avatar?: { url?: string, path: string } }) {
|
||||
return Actor.GET_ACTOR_AVATAR_URL(actor) || this.GET_DEFAULT_AVATAR_URL()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Actor as ActorServer, ActorImage } from '@shared/models'
|
||||
import { getAbsoluteAPIUrl } from '@app/helpers'
|
||||
import { Actor as ServerActor, ActorImage } from '@shared/models'
|
||||
|
||||
export abstract class Actor implements ActorServer {
|
||||
export abstract class Actor implements ServerActor {
|
||||
id: number
|
||||
name: string
|
||||
|
||||
|
@ -47,7 +47,7 @@ export abstract class Actor implements ActorServer {
|
|||
return host.trim() === thisHost
|
||||
}
|
||||
|
||||
protected constructor (hash: Partial<ActorServer>) {
|
||||
protected constructor (hash: Partial<ServerActor>) {
|
||||
this.id = hash.id
|
||||
this.url = hash.url ?? ''
|
||||
this.name = hash.name ?? ''
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<a *ngIf="displayOptions.avatar && displayOwnerVideoChannel()" class="avatar" [routerLink]="[ '/video-channels', video.byVideoChannel ]" [title]="channelLinkTitle">
|
||||
<img [src]="getAvatarUrl()" alt="" class="channel" />
|
||||
</a>
|
||||
<my-account-avatar *ngIf="displayOptions.avatar && displayOwnerAccount()" [account]="video.account" size="40" [href]="'/video-channels/' + video.byVideoChannel" [title]="channelLinkTitle"></my-account-avatar>
|
||||
<my-account-avatar *ngIf="displayOptions.avatar && displayOwnerAccount()" [account]="video.account" size="40" [internalHref]="'/video-channels/' + video.byVideoChannel" [title]="channelLinkTitle"></my-account-avatar>
|
||||
|
||||
<div class="w-100 d-flex flex-column">
|
||||
<a *ngIf="!videoHref" tabindex="-1" class="video-miniature-name"
|
||||
|
|
Loading…
Reference in New Issue