(snippetId: number)
| 337 | } |
| 338 | |
| 339 | async function duplicateSnippet(snippetId: number) { |
| 340 | try { |
| 341 | // Список не содержит тел фрагментов — источник копии загружается по id. |
| 342 | const { data: snippet } = await api.snippets.getSnippetsById( |
| 343 | String(snippetId), |
| 344 | ) |
| 345 | |
| 346 | const { data } = await api.snippets.postSnippets({ |
| 347 | name: `${snippet.name} - copy`, |
| 348 | folderId: snippet.folder?.id || null, |
| 349 | }) |
| 350 | |
| 351 | for (const content of snippet.contents) { |
| 352 | await api.snippets.postSnippetsByIdContents(String(data.id), { |
| 353 | label: content.label, |
| 354 | value: content.value, |
| 355 | language: content.language, |
| 356 | }) |
| 357 | } |
| 358 | |
| 359 | for (const tag of snippet.tags) { |
| 360 | await api.snippets.postSnippetsByIdTagsByTagId( |
| 361 | String(data.id), |
| 362 | String(tag.id), |
| 363 | ) |
| 364 | } |
| 365 | |
| 366 | await getSnippets(queryByLibraryOrFolderOrSearch.value) |
| 367 | } |
| 368 | catch (error) { |
| 369 | console.error(error) |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | async function createSnippetContent(snippetId: number) { |
| 374 | const lastContentIndex = selectedSnippet.value?.contents.length || 0 |
nothing calls this directly
no test coverage detected