diff options
Diffstat (limited to 'client/src/app/shared/shared-actor-image/actor-avatar-edit.component.ts')
-rw-r--r-- | client/src/app/shared/shared-actor-image/actor-avatar-edit.component.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/client/src/app/shared/shared-actor-image/actor-avatar-edit.component.ts b/client/src/app/shared/shared-actor-image/actor-avatar-edit.component.ts index 6f76172e9..d0d269489 100644 --- a/client/src/app/shared/shared-actor-image/actor-avatar-edit.component.ts +++ b/client/src/app/shared/shared-actor-image/actor-avatar-edit.component.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' |
2 | import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' | ||
2 | import { Notifier, ServerService } from '@app/core' | 3 | import { Notifier, ServerService } from '@app/core' |
3 | import { Account, VideoChannel } from '@app/shared/shared-main' | 4 | import { Account, VideoChannel } from '@app/shared/shared-main' |
4 | import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' | 5 | import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' |
@@ -20,6 +21,7 @@ export class ActorAvatarEditComponent implements OnInit { | |||
20 | @Input() editable = true | 21 | @Input() editable = true |
21 | @Input() displaySubscribers = true | 22 | @Input() displaySubscribers = true |
22 | @Input() displayUsername = true | 23 | @Input() displayUsername = true |
24 | @Input() previewImage = false | ||
23 | 25 | ||
24 | @Output() avatarChange = new EventEmitter<FormData>() | 26 | @Output() avatarChange = new EventEmitter<FormData>() |
25 | @Output() avatarDelete = new EventEmitter<void>() | 27 | @Output() avatarDelete = new EventEmitter<void>() |
@@ -28,7 +30,10 @@ export class ActorAvatarEditComponent implements OnInit { | |||
28 | maxAvatarSize = 0 | 30 | maxAvatarSize = 0 |
29 | avatarExtensions = '' | 31 | avatarExtensions = '' |
30 | 32 | ||
33 | preview: SafeResourceUrl | ||
34 | |||
31 | constructor ( | 35 | constructor ( |
36 | private sanitizer: DomSanitizer, | ||
32 | private serverService: ServerService, | 37 | private serverService: ServerService, |
33 | private notifier: Notifier | 38 | private notifier: Notifier |
34 | ) { } | 39 | ) { } |
@@ -57,14 +62,19 @@ export class ActorAvatarEditComponent implements OnInit { | |||
57 | formData.append('avatarfile', avatarfile) | 62 | formData.append('avatarfile', avatarfile) |
58 | this.avatarPopover?.close() | 63 | this.avatarPopover?.close() |
59 | this.avatarChange.emit(formData) | 64 | this.avatarChange.emit(formData) |
65 | |||
66 | if (this.previewImage) { | ||
67 | this.preview = this.sanitizer.bypassSecurityTrustResourceUrl(URL.createObjectURL(avatarfile)) | ||
68 | } | ||
60 | } | 69 | } |
61 | 70 | ||
62 | deleteAvatar () { | 71 | deleteAvatar () { |
72 | this.preview = undefined | ||
63 | this.avatarDelete.emit() | 73 | this.avatarDelete.emit() |
64 | } | 74 | } |
65 | 75 | ||
66 | hasAvatar () { | 76 | hasAvatar () { |
67 | return !!this.actor.avatar | 77 | return !!this.preview || !!this.actor.avatar |
68 | } | 78 | } |
69 | 79 | ||
70 | isChannel () { | 80 | isChannel () { |