MCPcopy Index your code
hub / github.com/massCodeIO/massCode / getOrCreateTagIds

Function getOrCreateTagIds

src/main/import/notes/persist.ts:114–143  ·  view source on GitHub ↗
(tags: string[] | undefined)

Source from the content-addressed store, hash-verified

112}
113
114function getOrCreateTagIds(tags: string[] | undefined): {
115 created: number
116 tagIds: number[]
117} {
118 const storage = useNotesStorage()
119 const tagIds: number[] = []
120 let created = 0
121
122 for (const rawTag of tags || []) {
123 const name = normalizeImportTag(rawTag)
124 if (!name) {
125 continue
126 }
127
128 const existing = storage.tags
129 .getTags()
130 .find(tag => tag.name.toLowerCase() === name.toLowerCase())
131
132 if (existing) {
133 tagIds.push(existing.id)
134 continue
135 }
136
137 const { id } = storage.tags.createTag(name)
138 tagIds.push(id)
139 created += 1
140 }
141
142 return { created, tagIds }
143}
144
145function createNote(
146 candidate: NoteImportCandidate,

Callers 1

createNoteFunction · 0.70

Calls 2

useNotesStorageFunction · 0.90
normalizeImportTagFunction · 0.90

Tested by

no test coverage detected