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

Function duplicateSnippet

src/renderer/composables/useSnippets.ts:339–371  ·  view source on GitHub ↗
(snippetId: number)

Source from the content-addressed store, hash-verified

337}
338
339async 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
373async function createSnippetContent(snippetId: number) {
374 const lastContentIndex = selectedSnippet.value?.contents.length || 0

Callers

nothing calls this directly

Calls 1

getSnippetsFunction · 0.70

Tested by

no test coverage detected