mirror of
https://github.com/block-core/angor-hub-old.git
synced 2026-01-31 07:34:21 +01:00
Updated post-event component HTML and TS files, and subscription service TS file, with changes to loading indicator, post loading logic, and subscription queue intervals.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<div class="mx-auto w-full max-w-5xl px-6 sm:px-8">
|
||||
<div class="flex min-w-0 flex-auto flex-col">
|
||||
<div *ngIf="loading" class="fixed inset-0 flex items-center justify-center z-50">
|
||||
<mat-progress-spinner mode="indeterminate"></mat-progress-spinner>
|
||||
<div *ngIf="loading" class="flex justify-center items-center py-8">
|
||||
<mat-progress-spinner mode="indeterminate" [diameter]="50"></mat-progress-spinner>
|
||||
</div>
|
||||
|
||||
<div *ngIf="!loading && post">
|
||||
|
||||
@@ -127,27 +127,44 @@ export class PostEventComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
async loadPost(postId: string): Promise<void> {
|
||||
|
||||
try {
|
||||
this.loading = true;
|
||||
|
||||
this.post = await this._storageService.getPostById(postId);
|
||||
|
||||
this.loadUserProfile();
|
||||
if (!this.post) {
|
||||
const filter: Filter[] = [
|
||||
{ ids: [postId], kinds: [1], limit: 1 }
|
||||
];
|
||||
|
||||
const subscriptionId = this._subscriptionService.addSubscriptions(filter, async (event: NostrEvent) => {
|
||||
this.post = event;
|
||||
console.log( this.post);
|
||||
|
||||
this._storageService.profile$.subscribe((data) => {
|
||||
if (data && data.pubKey === this.post.pubkey) {
|
||||
this.user = data.metadata;
|
||||
this._changeDetectorRef.detectChanges();
|
||||
}
|
||||
});
|
||||
|
||||
this.loading = false;
|
||||
await this._storageService.savePost(event);
|
||||
|
||||
this._changeDetectorRef.detectChanges();
|
||||
|
||||
if (subscriptionId) {
|
||||
this._subscriptionService.removeSubscriptionById(subscriptionId);
|
||||
}
|
||||
this.loading = false;
|
||||
});
|
||||
} else {
|
||||
this.loading = false;
|
||||
await this.loadUserProfile();
|
||||
}
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading post:', error);
|
||||
this._router.navigate(['/404']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getSafeUrl(url: string): SafeUrl {
|
||||
return this._sanitizer.bypassSecurityTrustUrl(url);
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ export class SubscriptionService {
|
||||
|
||||
private subscriptionQueue: Subscription[] = [];
|
||||
private isProcessingQueue = false;
|
||||
private queueInterval = 3000;
|
||||
private queueInterval = 1000;
|
||||
private maxSubscriptionsPerBatch = 5;
|
||||
private debounceInterval = 5000;
|
||||
private debounceInterval = 1000;
|
||||
private lastActionTimestamp = new Map<string, number>();
|
||||
|
||||
constructor(private relayService: RelayService) {
|
||||
|
||||
Reference in New Issue
Block a user