( snippetId: number, contentId: number, data: SnippetContentsUpdate, )
| 482 | } |
| 483 | |
| 484 | async function updateSnippetContent( |
| 485 | snippetId: number, |
| 486 | contentId: number, |
| 487 | data: SnippetContentsUpdate, |
| 488 | ) { |
| 489 | markPersistedStorageMutation() |
| 490 | await api.snippets.patchSnippetsByIdContentsByContentId( |
| 491 | String(snippetId), |
| 492 | String(contentId), |
| 493 | data, |
| 494 | ) |
| 495 | |
| 496 | // Тел фрагментов в списке нет — обновляется только выбранная запись, |
| 497 | // без перезагрузки списка на каждое сохранение при наборе текста. |
| 498 | const record = selectedSnippetRecord.value |
| 499 | if (record?.id === snippetId) { |
| 500 | selectedSnippetRecord.value = { |
| 501 | ...record, |
| 502 | contents: record.contents.map(content => |
| 503 | content.id === contentId ? { ...content, ...data } : content, |
| 504 | ), |
| 505 | updatedAt: Date.now(), |
| 506 | } |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | async function deleteSnippet(snippetId: number) { |
| 511 | markPersistedStorageMutation() |
no test coverage detected