mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
deduplicate labels when there are case-insensitive identical names
This commit is contained in:
parent
6f03b214b5
commit
25fb9fd698
1 changed files with 11 additions and 14 deletions
|
|
@ -41,21 +41,18 @@ export const findOrCreateLabels = async (
|
|||
labels: CreateLabelInput[],
|
||||
userId: string
|
||||
): Promise<Label[]> => {
|
||||
// create labels if not exist
|
||||
await authTrx(
|
||||
async (tx) =>
|
||||
tx.withRepository(labelRepository).createLabels(labels, userId),
|
||||
undefined,
|
||||
userId
|
||||
)
|
||||
|
||||
// find labels
|
||||
return authTrx(
|
||||
async (tx) =>
|
||||
tx.withRepository(labelRepository).findByNames(
|
||||
labels.map((l) => l.name),
|
||||
userId
|
||||
),
|
||||
async (tx) => {
|
||||
const repo = tx.withRepository(labelRepository)
|
||||
// create labels if not exist
|
||||
await repo.createLabels(labels, userId)
|
||||
|
||||
// find labels by names
|
||||
return repo.findBy({
|
||||
name: In(labels.map((l) => l.name)),
|
||||
user: { id: userId },
|
||||
})
|
||||
},
|
||||
undefined,
|
||||
userId
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue