-
+
+
diff --git a/src/app/components/post-event/post-event.component.ts b/src/app/components/post-event/post-event.component.ts
index 383a8a5..d087799 100644
--- a/src/app/components/post-event/post-event.component.ts
+++ b/src/app/components/post-event/post-event.component.ts
@@ -127,27 +127,44 @@ export class PostEventComponent implements OnInit, OnDestroy {
}
async loadPost(postId: string): Promise {
-
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);
}
diff --git a/src/app/services/subscription.service.ts b/src/app/services/subscription.service.ts
index eb6e812..57fef89 100644
--- a/src/app/services/subscription.service.ts
+++ b/src/app/services/subscription.service.ts
@@ -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();
constructor(private relayService: RelayService) {