mirror of
https://github.com/block-core/blockcore-notes.git
synced 2024-09-29 06:20:42 +00:00
Fix issue with subscription retry logic
This commit is contained in:
parent
0cb83fed07
commit
5c7c00541b
@ -51,7 +51,7 @@ export class ProfileComponent {
|
||||
this.subscriptions.push(
|
||||
this.profileService.profile$.subscribe((profile) => {
|
||||
if (!profile) {
|
||||
profile = this.defaultProfile();
|
||||
profile = this.defaultProfile(this.appState.getPublicKey());
|
||||
}
|
||||
|
||||
console.log('PROFILE SERVICE:', profile);
|
||||
@ -64,7 +64,7 @@ export class ProfileComponent {
|
||||
);
|
||||
}
|
||||
|
||||
defaultProfile(): NostrProfileDocument {
|
||||
defaultProfile(pubkey: string): NostrProfileDocument {
|
||||
return {
|
||||
name: '',
|
||||
about: '',
|
||||
@ -75,7 +75,7 @@ export class ProfileComponent {
|
||||
website: '',
|
||||
created: Math.floor(Date.now() / 1000),
|
||||
verifications: [],
|
||||
pubkey: this.appState.getPublicKey(),
|
||||
pubkey: pubkey,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -461,6 +461,12 @@ export class RelayService {
|
||||
subscribeToFollowing(relay: Relay) {
|
||||
const authors = this.profileService.profiles.map((p) => p.pubkey);
|
||||
|
||||
// Just skip subscription if we are not following anyone yet.
|
||||
if (authors.length === 0) {
|
||||
console.log('Skipping subscription, zero following.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Append ourself to the authors list so we receive everything we publish to any relay.
|
||||
authors.push(this.appState.getPublicKey());
|
||||
|
||||
@ -482,8 +488,12 @@ export class RelayService {
|
||||
|
||||
if (sub.loading) {
|
||||
console.log('Unsubbing and restarting subscription.', relay);
|
||||
sub.unsub();
|
||||
this.subscribeToFollowing(relay);
|
||||
|
||||
// Only re-attempt the subscription if we actually have an active connection to this relay.
|
||||
if (relay.status === 1) {
|
||||
sub.unsub();
|
||||
this.subscribeToFollowing(relay);
|
||||
}
|
||||
}
|
||||
}, 5 * 60 * 1000);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user