MCPcopy Create free account
hub / github.com/block/buzz / fetchProject

Function fetchProject

desktop/src/features/projects/hooks.ts:253–278  ·  view source on GitHub ↗
(projectId: string)

Source from the content-addressed store, hash-verified

251}
252
253async function fetchProject(projectId: string): Promise<Project | null> {
254 const { owner, dtag } = parseProjectRouteId(projectId);
255 const events = await relayClient.fetchEvents({
256 kinds: [KIND_REPO_ANNOUNCEMENT],
257 ...(owner ? { authors: [owner] } : {}),
258 "#d": [dtag],
259 limit: 10,
260 });
261
262 const deduped = dedup(events).filter(
263 (event) => !owner || event.pubkey.toLowerCase() === owner,
264 );
265 const project = deduped.length > 0 ? eventToProject(deduped[0]) : null;
266 if (!project) {
267 return null;
268 }
269
270 const deletionEvents = await relayClient.fetchEvents({
271 kinds: [KIND_DELETION],
272 authors: [project.owner],
273 "#a": [project.repoAddress],
274 limit: 10,
275 });
276
277 return isDeletedByA(project, deletionEvents) ? null : project;
278}
279
280function eventToRepoState(event: RelayEvent): RepoState {
281 const branches: RepoState["branches"] = [];

Callers 1

useProjectQueryFunction · 0.85

Calls 5

parseProjectRouteIdFunction · 0.85
eventToProjectFunction · 0.85
isDeletedByAFunction · 0.85
dedupFunction · 0.70
fetchEventsMethod · 0.45

Tested by

no test coverage detected