(tags: string[] | undefined)
| 112 | } |
| 113 | |
| 114 | function 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 | |
| 145 | function createNote( |
| 146 | candidate: NoteImportCandidate, |
no test coverage detected