if (actor && actor.avatar) return absoluteAPIUrl + actor.avatar.path
+ this.GET_DEFAULT_AVATAR_URL()
+ }
+
+ static GET_DEFAULT_AVATAR_URL () {
return window.location.origin + '/client/assets/images/default-avatar.png'
}
import { Directive, ElementRef, HostListener, Output, EventEmitter } from '@angular/core'
import { Router } from '@angular/router'
-
-type ElementEvent = Omit<Event, 'target'> & {
- target: HTMLInputElement
-}
+import { ElementEvent } from '@app/shared/misc/utils'
@Directive({
selector: '[timestampRouteTransformer]'
import { environment } from '../../../environments/environment'
import { AuthService } from '../../core/auth'
+type ElementEvent = Omit<Event, 'target'> & {
+ target: HTMLElement
+}
+
function getParameterByName (name: string, url: string) {
if (!url) url = window.location.href
name = name.replace(/[\[\]]/g, '\\$&')
}
export {
+ ElementEvent,
sortBy,
durationToString,
lineFeedToHtml,
<img
class="comment-avatar"
[src]="comment.accountAvatarUrl"
+ (error)="switchToDefaultAvatar($event)"
alt="Avatar"
/>
</a>
import { Account } from '@app/shared/account/account.model'
import { Notifier } from '@app/core'
import { UserService } from '@app/shared'
+import { Actor } from '@app/shared/actor/actor.model'
@Component({
selector: 'my-video-comment',
)
}
+ switchToDefaultAvatar ($event: Event) {
+ ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL()
+ }
+
private getUserIfNeeded (account: Account) {
if (!account.userId) return
if (!this.authService.isLoggedIn()) return