Browse Source

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?
master
DanConwayDev 2 years ago
parent
commit
f754eecb16
No known key found for this signature in database
GPG Key ID: 68E15486D73F75E1
  1. 4
      src/lib/stores/Issue.ts
  2. 8
      src/lib/stores/Issues.ts
  3. 12
      src/lib/stores/Proposal.ts
  4. 10
      src/lib/stores/Proposals.ts

4
src/lib/stores/Issue.ts

@ -70,10 +70,10 @@ export const ensureIssueFull = (repo_identifier: string, issue_id: string) => { @@ -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)
)

8
src/lib/stores/Issues.ts

@ -64,7 +64,7 @@ export const ensureIssueSummaries = async (repo_id: string | undefined) => { @@ -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) => { @@ -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( @@ -170,7 +170,7 @@ function getAndUpdateIssueStatus(
'#e': issues.summaries.map((issue) => issue.id),
},
{
closeOnEose: true,
closeOnEose: false,
},
NDKRelaySet.fromRelayUrls(relays, ndk)
)

12
src/lib/stores/Proposal.ts

@ -30,6 +30,8 @@ let sub: NDKSubscription @@ -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 = ( @@ -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 = ( @@ -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 = ( @@ -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)
}
}

10
src/lib/stores/Proposals.ts

@ -59,7 +59,7 @@ export const ensureProposalSummaries = async (repo_id: string | undefined) => { @@ -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) => { @@ -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) => { @@ -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) => { @@ -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( @@ -187,7 +187,7 @@ function getAndUpdateProposalStatus(
'#e': proposals.summaries.map((proposal) => proposal.id),
},
{
closeOnEose: true,
closeOnEose: false,
},
NDKRelaySet.fromRelayUrls(relays, ndk)
)

Loading…
Cancel
Save