MCPcopy Create free account
hub / github.com/massCodeIO/massCode / apply

Function apply

src/renderer/composables/useSnippets.ts:421–441  ·  view source on GitHub ↗
(collection?: SnippetsResponse)

Source from the content-addressed store, hash-verified

419 const now = Date.now()
420
421 function apply(collection?: SnippetsResponse) {
422 if (!collection) {
423 return collection
424 }
425
426 const index = collection.findIndex(s => s.id === snippetId)
427 if (index === -1) {
428 return collection
429 }
430
431 const next = [...collection]
432 next[index] = {
433 ...next[index],
434 ...(data.name !== undefined ? { name: data.name } : {}),
435 ...(data.description !== undefined
436 ? { description: data.description }
437 : {}),
438 updatedAt: now,
439 }
440 return next
441 }
442
443 snippets.value = apply(snippets.value)
444 snippetsBySearch.value = apply(snippetsBySearch.value)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected