mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Delete highlights, labels and other metadata when soft delete pages
This commit is contained in:
parent
77327d1929
commit
e1de55bea0
2 changed files with 19 additions and 4 deletions
|
|
@ -437,11 +437,19 @@ export const getArticleResolver: ResolverFn<
|
|||
// We allow the backend to use the ID instead of a slug to fetch the article
|
||||
const page =
|
||||
(await getPageByParam(
|
||||
{ userId: claims.uid, slug },
|
||||
{
|
||||
userId: claims.uid,
|
||||
slug,
|
||||
state: ArticleSavingRequestStatus.Succeeded,
|
||||
},
|
||||
includeOriginalHtml
|
||||
)) ||
|
||||
(await getPageByParam(
|
||||
{ userId: claims.uid, _id: slug },
|
||||
{
|
||||
userId: claims.uid,
|
||||
_id: slug,
|
||||
state: ArticleSavingRequestStatus.Succeeded,
|
||||
},
|
||||
includeOriginalHtml
|
||||
))
|
||||
|
||||
|
|
@ -643,10 +651,16 @@ export const setBookmarkArticleResolver = authorized<
|
|||
return { errorCodes: [SetBookmarkArticleErrorCode.NotFound] }
|
||||
}
|
||||
|
||||
// delete the page
|
||||
// delete the page and its metadata
|
||||
const deleted = await updatePage(
|
||||
pageRemoved.id,
|
||||
{ state: ArticleSavingRequestStatus.Deleted },
|
||||
{
|
||||
state: ArticleSavingRequestStatus.Deleted,
|
||||
labels: [],
|
||||
highlights: [],
|
||||
readingProgressAnchorIndex: 0,
|
||||
readingProgressPercent: 0,
|
||||
},
|
||||
{ pubsub, uid }
|
||||
)
|
||||
if (!deleted) {
|
||||
|
|
|
|||
|
|
@ -688,6 +688,7 @@ describe('Article API', () => {
|
|||
await graphqlRequest(query, authToken).expect(200)
|
||||
const page = await getPageById(articleId)
|
||||
expect(page?.state).to.eql(ArticleSavingRequestStatus.Deleted)
|
||||
expect(page?.highlights).to.eql([])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue