-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
436 additions
and
534 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/app/components/post-event/post-profile/post-profile.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="flex items-center"> | ||
<a [href]="'/profile/' + pubkey" class="flex items-center group"> | ||
<img class="mr-4 h-10 w-10 rounded-full object-cover" [src]="displayAvatar" | ||
[alt]="displayName" | ||
onerror="this.onerror=null; this.src='/images/avatars/avatar-placeholder.png';" /> | ||
<div class="flex flex-col"> | ||
<span class="font-semibold leading-none">{{ displayName }}</span> | ||
<span class="text-secondary mt-1 text-sm leading-none">{{ created_at | ago}}</span> | ||
</div> | ||
</a> | ||
</div> | ||
|
Empty file.
61 changes: 61 additions & 0 deletions
61
src/app/components/post-event/post-profile/post-profile.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { ChangeDetectorRef, Component, Input, OnDestroy, OnInit } from '@angular/core'; | ||
import { Subscription } from 'rxjs'; | ||
import { StorageService } from 'app/services/storage.service'; | ||
import { CommonModule } from '@angular/common'; | ||
import { AgoPipe } from "../../../shared/pipes/ago.pipe"; | ||
|
||
@Component({ | ||
selector: 'app-post-profile', | ||
standalone: true, | ||
templateUrl: './post-profile.component.html', | ||
styleUrls: ['./post-profile.component.scss'], | ||
imports: [CommonModule, AgoPipe] | ||
}) | ||
export class PostProfileComponent implements OnInit, OnDestroy { | ||
@Input() pubkey!: string; | ||
@Input() avatarUrl?: string; | ||
@Input() created_at?: string; | ||
|
||
user: any; | ||
private subscription!: Subscription; | ||
constructor( | ||
private _changeDetectorRef: ChangeDetectorRef, | ||
private _storageService: StorageService | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.loadUserProfile(); | ||
|
||
this.subscription = this._storageService.profile$.subscribe((data) => { | ||
if (data && data.pubKey === this.pubkey) { | ||
this.user = data.metadata; | ||
this._changeDetectorRef.detectChanges(); | ||
} | ||
}); | ||
} | ||
|
||
private async loadUserProfile(): Promise<void> { | ||
const metadata = await this._storageService.getProfile(this.pubkey); | ||
this.user = metadata || {}; | ||
this._changeDetectorRef.detectChanges(); | ||
} | ||
|
||
get displayName(): string { | ||
return this.user?.display_name || this.user?.name || this.shortenPubkey(this.pubkey); | ||
} | ||
|
||
get displayAvatar(): string { | ||
return this.user?.picture || this.avatarUrl || '/images/avatars/avatar-placeholder.png'; | ||
} | ||
|
||
shortenPubkey(pubkey: string): string { | ||
if (!pubkey) return ''; | ||
return `${pubkey.slice(0, 8)}...${pubkey.slice(-8)}`; | ||
} | ||
|
||
ngOnDestroy(): void { | ||
if (this.subscription) { | ||
this.subscription.unsubscribe(); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/app/components/post-event/replay-profile/replay-profile.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.