mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
revert soft deletes all the labels and highlights attached to the deleted item
This commit is contained in:
parent
38ee6c1331
commit
abfa15e56f
2 changed files with 2 additions and 32 deletions
|
|
@ -723,12 +723,6 @@ export const softDeleteLibraryItem = async (
|
|||
deletedAt: new Date(),
|
||||
})
|
||||
|
||||
// delete all labels for this item
|
||||
await tx.getRepository(EntityLabel).delete({ libraryItemId: id })
|
||||
|
||||
// delete all highlights for this item
|
||||
await tx.getRepository(Highlight).delete({ libraryItem: { id } })
|
||||
|
||||
return itemRepo.findOneByOrFail({ id })
|
||||
},
|
||||
undefined,
|
||||
|
|
@ -751,14 +745,11 @@ export const updateLibraryItem = async (
|
|||
async (tx) => {
|
||||
const itemRepo = tx.withRepository(libraryItemRepository)
|
||||
|
||||
// reset deletedAt and archivedAt
|
||||
// reset archivedAt
|
||||
switch (libraryItem.state) {
|
||||
case LibraryItemState.Archived:
|
||||
libraryItem.archivedAt = new Date()
|
||||
break
|
||||
case LibraryItemState.Deleted:
|
||||
libraryItem.deletedAt = new Date()
|
||||
break
|
||||
case LibraryItemState.Processing:
|
||||
case LibraryItemState.Succeeded:
|
||||
libraryItem.archivedAt = null
|
||||
|
|
|
|||
|
|
@ -711,39 +711,18 @@ describe('Article API', () => {
|
|||
}
|
||||
const item = await createOrUpdateLibraryItem(itemToSave, user.id)
|
||||
itemId = item.id
|
||||
|
||||
await createAndSaveLabelsInLibraryItem(itemId, user.id, [
|
||||
{
|
||||
name: 'test label 2',
|
||||
},
|
||||
])
|
||||
await createHighlight(
|
||||
{
|
||||
shortId: generateFakeShortId(),
|
||||
user: { id: user.id },
|
||||
quote: 'test quote 2',
|
||||
},
|
||||
itemId,
|
||||
user.id
|
||||
)
|
||||
})
|
||||
|
||||
after(async () => {
|
||||
await deleteLibraryItemById(itemId, user.id)
|
||||
})
|
||||
|
||||
it('marks an item as deleted and deletes all the labels and highlights attached to the item', async () => {
|
||||
it('soft deletes the item', async () => {
|
||||
await graphqlRequest(setBookmarkQuery(itemId, false), authToken).expect(
|
||||
200
|
||||
)
|
||||
const item = await findLibraryItemById(itemId, user.id)
|
||||
expect(item?.state).to.eql(LibraryItemState.Deleted)
|
||||
|
||||
const labels = await findLabelsByLibraryItemId(itemId, user.id)
|
||||
expect(labels).to.be.empty
|
||||
|
||||
const highlights = await findHighlightsByLibraryItemId(itemId, user.id)
|
||||
expect(highlights).to.be.empty
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue