MCPcopy Create free account
hub / github.com/dailydotdev/apps / updateSearchData

Function updateSearchData

packages/shared/src/graphql/search.ts:397–430  ·  view source on GitHub ↗
(
  previous: Search,
  chunk: Partial<SearchChunk>,
)

Source from the content-addressed store, hash-verified

395};
396
397export const updateSearchData = (
398 previous: Search,
399 chunk: Partial<SearchChunk>,
400): Search => {
401 const updated = {
402 ...previous,
403 chunks: [{ ...previous?.chunks?.[0], ...chunk }],
404 };
405 const currentChunk = updated.chunks[0];
406
407 if (!currentChunk) {
408 return updated;
409 }
410
411 if (chunk.error) {
412 return updated;
413 }
414
415 if (chunk.status) {
416 currentChunk.progress = (currentChunk.progress ?? 0) + 1;
417 }
418
419 if (chunk.completedAt) {
420 currentChunk.progress = currentChunk.steps;
421 }
422
423 if (isNullOrUndefined(chunk.response)) {
424 return updated;
425 }
426
427 currentChunk.response = (previous.chunks[0]?.response ?? '') + chunk.response;
428
429 return updated;
430};
431
432interface SearchUrlParams {
433 id?: string;

Callers

nothing calls this directly

Calls 1

isNullOrUndefinedFunction · 0.90

Tested by

no test coverage detected