|
|
|
@ -88,12 +88,46 @@ export const ensureRepoCollection = ( |
|
|
|
events: [...repo_collection.events, repo_event as RepoEvent], |
|
|
|
events: [...repo_collection.events, repo_event as RepoEvent], |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
fetchReferencedBy( |
|
|
|
|
|
|
|
repo_event, |
|
|
|
|
|
|
|
unique_commit_or_identifier, |
|
|
|
|
|
|
|
collection_for_unique_commit |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
// TODO fetch stargazers
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
sub.on('eose', () => { |
|
|
|
|
|
|
|
// still awaiting reference_by at this point
|
|
|
|
|
|
|
|
repos[unique_commit_or_identifier].update((repo_collection) => { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
...repo_collection, |
|
|
|
|
|
|
|
loading: false, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
repos[unique_commit_or_identifier].update((collection) => { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
...collection, |
|
|
|
|
|
|
|
events: collection.events.map((e) => ({ ...e, loading: false })), |
|
|
|
|
|
|
|
loading: false, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, 5000) |
|
|
|
|
|
|
|
return repos[unique_commit_or_identifier] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fetchReferencedBy = ( |
|
|
|
|
|
|
|
repo_event: RepoEvent, |
|
|
|
|
|
|
|
unique_commit_or_identifier: string, |
|
|
|
|
|
|
|
collection_for_unique_commit: boolean |
|
|
|
|
|
|
|
) => { |
|
|
|
const relays_to_use = |
|
|
|
const relays_to_use = |
|
|
|
repo_event.relays.length < 3 |
|
|
|
repo_event.relays.length < 3 |
|
|
|
? repo_event.relays |
|
|
|
? repo_event.relays |
|
|
|
: [...base_relays].concat(repo_event.relays) |
|
|
|
: [...base_relays].concat(repo_event.relays) |
|
|
|
|
|
|
|
|
|
|
|
// get references
|
|
|
|
|
|
|
|
const ref_sub = ndk.subscribe( |
|
|
|
const ref_sub = ndk.subscribe( |
|
|
|
{ |
|
|
|
{ |
|
|
|
'#a': [ |
|
|
|
'#a': [ |
|
|
|
@ -145,13 +179,8 @@ export const ensureRepoCollection = ( |
|
|
|
return latest_ref_event |
|
|
|
return latest_ref_event |
|
|
|
}), |
|
|
|
}), |
|
|
|
] |
|
|
|
] |
|
|
|
const still_loading_events_in_collection = events.some( |
|
|
|
const still_loading_events_in_collection = events.some((e) => e.loading) |
|
|
|
(e) => e.loading |
|
|
|
if (collection_for_unique_commit && !still_loading_events_in_collection) |
|
|
|
) |
|
|
|
|
|
|
|
if ( |
|
|
|
|
|
|
|
collection_for_unique_commit && |
|
|
|
|
|
|
|
!still_loading_events_in_collection |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
addEventsWithMatchingIdentifiers(events) |
|
|
|
addEventsWithMatchingIdentifiers(events) |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
@ -165,28 +194,6 @@ export const ensureRepoCollection = ( |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
sub.on('eose', () => { |
|
|
|
|
|
|
|
// still awaiting reference_by at this point
|
|
|
|
|
|
|
|
repos[unique_commit_or_identifier].update((repo_collection) => { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
...repo_collection, |
|
|
|
|
|
|
|
loading: false, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
repos[unique_commit_or_identifier].update((collection) => { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
...collection, |
|
|
|
|
|
|
|
events: collection.events.map((e) => ({ ...e, loading: false })), |
|
|
|
|
|
|
|
loading: false, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, 5000) |
|
|
|
|
|
|
|
return repos[unique_commit_or_identifier] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const eventToRepoEvent = (event: NDKEvent): RepoEvent | undefined => { |
|
|
|
export const eventToRepoEvent = (event: NDKEvent): RepoEvent | undefined => { |
|
|
|
if (event.kind !== repo_kind) return undefined |
|
|
|
if (event.kind !== repo_kind) return undefined |
|
|
|
|