From f754eecb16fd032b46478d7b363ad77e8226e2bc Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 28 Feb 2024 21:08:31 +0000 Subject: [PATCH] fix: keep selected subscriptions open this doesnt apply to subscriptions that we for many types simultainiously ie repos and users also extend limit from 50 to 100. if we need to go higher, will we need to introduce a system to get around relay limits? --- src/lib/stores/Issue.ts | 4 ++-- src/lib/stores/Issues.ts | 8 ++++---- src/lib/stores/Proposal.ts | 12 ++++++++---- src/lib/stores/Proposals.ts | 10 +++++----- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/lib/stores/Issue.ts b/src/lib/stores/Issue.ts index bf7902b..b18854f 100644 --- a/src/lib/stores/Issue.ts +++ b/src/lib/stores/Issue.ts @@ -70,10 +70,10 @@ export const ensureIssueFull = (repo_identifier: string, issue_id: string) => { sub = ndk.subscribe( { ids: [issue_id], - limit: 50, + limit: 100, }, { - closeOnEose: true, + closeOnEose: false, }, NDKRelaySet.fromRelayUrls(relays_to_use, ndk) ) diff --git a/src/lib/stores/Issues.ts b/src/lib/stores/Issues.ts index c666d8e..27f03a8 100644 --- a/src/lib/stores/Issues.ts +++ b/src/lib/stores/Issues.ts @@ -64,7 +64,7 @@ export const ensureIssueSummaries = async (repo_id: string | undefined) => { let relays_to_use = [...base_relays] let filter: NDKFilter = { kinds: [issue_kind], - limit: 50, + limit: 100, } if (repo_id) { @@ -86,14 +86,14 @@ export const ensureIssueSummaries = async (repo_id: string | undefined) => { '#a': repo.maintainers.map( (m) => `${repo_kind}:${m.hexpubkey}:${repo.identifier}` ), - limit: 50, + limit: 100, } } sub = ndk.subscribe( filter, { - closeOnEose: true, + closeOnEose: false, }, NDKRelaySet.fromRelayUrls(relays_to_use, ndk) ) @@ -170,7 +170,7 @@ function getAndUpdateIssueStatus( '#e': issues.summaries.map((issue) => issue.id), }, { - closeOnEose: true, + closeOnEose: false, }, NDKRelaySet.fromRelayUrls(relays, ndk) ) diff --git a/src/lib/stores/Proposal.ts b/src/lib/stores/Proposal.ts index afaf8c7..5cb1b31 100644 --- a/src/lib/stores/Proposal.ts +++ b/src/lib/stores/Proposal.ts @@ -30,6 +30,8 @@ let sub: NDKSubscription let sub_replies: NDKSubscription +const sub_revisions: NDKSubscription[] = [] + let revision_ids_queried: string[] export const ensureProposalFull = ( @@ -45,6 +47,7 @@ export const ensureProposalFull = ( if (sub) sub.stop() if (sub_replies) sub_replies.stop() + sub_revisions.forEach((sub) => sub.stop()) selected_proposal_repo_id = repo_identifier selected_proposal_id = proposal_id @@ -76,10 +79,10 @@ export const ensureProposalFull = ( sub = ndk.subscribe( { ids: [proposal_id], - limit: 50, + limit: 100, }, { - closeOnEose: true, + closeOnEose: false, }, NDKRelaySet.fromRelayUrls(relays_to_use, ndk) ) @@ -193,16 +196,17 @@ export const ensureProposalFull = ( const sub_revision_replies = ndk.subscribe( { '#e': [event.id], - limit: 50, + limit: 100, }, { - closeOnEose: true, + closeOnEose: false, }, NDKRelaySet.fromRelayUrls(relays_to_use, ndk) ) sub_revision_replies.on('event', (event: NDKEvent) => { process_replies(event) }) + sub_revisions.push(sub_revision_replies) } } diff --git a/src/lib/stores/Proposals.ts b/src/lib/stores/Proposals.ts index 55f393e..e772d37 100644 --- a/src/lib/stores/Proposals.ts +++ b/src/lib/stores/Proposals.ts @@ -59,7 +59,7 @@ export const ensureProposalSummaries = async (repo_id: string | undefined) => { let relays_to_use = [...base_relays] let filter: NDKFilter = { kinds: [patch_kind], - limit: 50, + limit: 100, } if (repo_id) { @@ -84,7 +84,7 @@ export const ensureProposalSummaries = async (repo_id: string | undefined) => { '#a': repo.maintainers.map( (m) => `${repo_kind}:${m.hexpubkey}:${repo.identifier}` ), - limit: 50, + limit: 100, } } else { filter = { @@ -93,7 +93,7 @@ export const ensureProposalSummaries = async (repo_id: string | undefined) => { (m) => `${repo_kind}:${m.hexpubkey}:${repo.identifier}` ), '#t': ['root'], - limit: 50, + limit: 100, } } } @@ -101,7 +101,7 @@ export const ensureProposalSummaries = async (repo_id: string | undefined) => { sub = ndk.subscribe( filter, { - closeOnEose: true, + closeOnEose: false, }, NDKRelaySet.fromRelayUrls(relays_to_use, ndk) ) @@ -187,7 +187,7 @@ function getAndUpdateProposalStatus( '#e': proposals.summaries.map((proposal) => proposal.id), }, { - closeOnEose: true, + closeOnEose: false, }, NDKRelaySet.fromRelayUrls(relays, ndk) )