mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
fix deleted labels and highlights are still searchable
This commit is contained in:
parent
51c1d33a09
commit
8f39985f0f
2 changed files with 21 additions and 11 deletions
|
|
@ -198,4 +198,10 @@ export class LibraryItem {
|
|||
|
||||
@Column('text')
|
||||
folder!: string
|
||||
|
||||
@Column('text')
|
||||
labelNames?: string[]
|
||||
|
||||
@Column('text')
|
||||
highlightAnnotations?: string[]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -873,17 +873,6 @@ export const createOrUpdateLibraryItem = async (
|
|||
|
||||
if (existingLibraryItem) {
|
||||
const id = existingLibraryItem.id
|
||||
// update existing library item
|
||||
const newItem = await repo.save({
|
||||
...libraryItem,
|
||||
id,
|
||||
slug: existingLibraryItem.slug, // keep the original slug
|
||||
})
|
||||
|
||||
// delete the new item if it's different from the existing one
|
||||
if (libraryItem.id && libraryItem.id !== id) {
|
||||
await repo.delete(libraryItem.id)
|
||||
}
|
||||
|
||||
try {
|
||||
// delete labels and highlights if the item was deleted
|
||||
|
|
@ -898,12 +887,27 @@ export const createOrUpdateLibraryItem = async (
|
|||
await tx.getRepository(EntityLabel).delete({
|
||||
libraryItemId: existingLibraryItem.id,
|
||||
})
|
||||
|
||||
libraryItem.labelNames = []
|
||||
libraryItem.highlightAnnotations = []
|
||||
}
|
||||
} catch (error) {
|
||||
// continue to save the item even if we failed to delete labels and highlights
|
||||
logger.error('Failed to delete labels and highlights', error)
|
||||
}
|
||||
|
||||
// update existing library item
|
||||
const newItem = await repo.save({
|
||||
...libraryItem,
|
||||
id,
|
||||
slug: existingLibraryItem.slug, // keep the original slug
|
||||
})
|
||||
|
||||
// delete the new item if it's different from the existing one
|
||||
if (libraryItem.id && libraryItem.id !== id) {
|
||||
await repo.delete(libraryItem.id)
|
||||
}
|
||||
|
||||
return newItem
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue