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

Function createNote

src/renderer/composables/spaces/notes/useNotes.ts:421–455  ·  view source on GitHub ↗
(payload?: CreateNotePayload)

Source from the content-addressed store, hash-verified

419}
420
421async function createNote(payload?: CreateNotePayload) {
422 try {
423 const targetFolderId = notesState.folderId || null
424 const existingNames = await getNoteNamesForCreate(targetFolderId)
425 const requestedName = payload?.name?.trim()
426 const hasRequestedName = existingNames.some(
427 name => name.trim().toLowerCase() === requestedName?.toLowerCase(),
428 )
429 const nextNoteName
430 = requestedName && !hasRequestedName
431 ? requestedName
432 : getNextIndexedName(
433 requestedName || i18n.t('notes.untitled'),
434 existingNames,
435 )
436
437 markPersistedStorageMutation()
438 const { data } = await api.notes.postNotes({
439 name: nextNoteName,
440 folderId: targetFolderId,
441 ...(payload?.properties ? { properties: payload.properties } : {}),
442 })
443
444 useDonations().incrementCreated('notes')
445
446 ensureCreateResultCanBeListed(payload)
447
448 await getNotes(queryByLibraryOrFolderOrSearch.value)
449
450 return Number(data.id)
451 }
452 catch (error) {
453 console.error(error)
454 }
455}
456
457async function createNoteAndSelect(payload?: CreateNotePayload) {
458 notesCreateKind.value = 'note'

Callers 1

Calls 6

useDonationsFunction · 0.90
getNoteNamesForCreateFunction · 0.85
getNextIndexedNameFunction · 0.70
getNotesFunction · 0.70

Tested by

no test coverage detected