(collection?: SnippetsResponse)
| 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) |
no outgoing calls
no test coverage detected