mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
refresh index after altering the page state or adding/removing/updating labels/highlights
This commit is contained in:
parent
7fd75a02ea
commit
ceaa7b0356
5 changed files with 24 additions and 7 deletions
|
|
@ -662,6 +662,12 @@ export const setBookmarkArticleResolver = authorized<
|
|||
return { errorCodes: [SetBookmarkArticleErrorCode.NotFound] }
|
||||
}
|
||||
|
||||
const pageContext = {
|
||||
pubsub,
|
||||
uid,
|
||||
refresh: true, // refresh to make sure the page is deleted
|
||||
}
|
||||
|
||||
if (!bookmark) {
|
||||
// delete the page and its metadata
|
||||
const deleted = await updatePage(
|
||||
|
|
@ -673,7 +679,7 @@ export const setBookmarkArticleResolver = authorized<
|
|||
readingProgressAnchorIndex: 0,
|
||||
readingProgressPercent: 0,
|
||||
},
|
||||
{ pubsub, uid }
|
||||
pageContext
|
||||
)
|
||||
if (!deleted) {
|
||||
return { errorCodes: [SetBookmarkArticleErrorCode.NotFound] }
|
||||
|
|
@ -715,10 +721,7 @@ export const setBookmarkArticleResolver = authorized<
|
|||
userId: uid,
|
||||
slug: generateSlug(page.title),
|
||||
}
|
||||
const updated = await updatePage(articleID, pageUpdated, {
|
||||
pubsub,
|
||||
uid,
|
||||
})
|
||||
const updated = await updatePage(articleID, pageUpdated, pageContext)
|
||||
if (!updated) {
|
||||
return { errorCodes: [SetBookmarkArticleErrorCode.NotFound] }
|
||||
}
|
||||
|
|
@ -1175,6 +1178,7 @@ export const setFavoriteArticleResolver = authorized<
|
|||
{
|
||||
uid,
|
||||
pubsub,
|
||||
refresh: true,
|
||||
},
|
||||
page.id,
|
||||
label
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ export const createHighlightResolver = authorized<
|
|||
!(await addHighlightToPage(pageId, highlight, {
|
||||
pubsub,
|
||||
uid: claims.uid,
|
||||
refresh: true,
|
||||
}))
|
||||
) {
|
||||
return {
|
||||
|
|
@ -186,7 +187,7 @@ export const mergeHighlightResolver = authorized<
|
|||
const merged = await updatePage(
|
||||
pageId,
|
||||
{ highlights: pageHighlights.concat(highlight) },
|
||||
{ pubsub, uid: claims.uid }
|
||||
{ pubsub, uid: claims.uid, refresh: true }
|
||||
)
|
||||
if (!merged) {
|
||||
throw new Error('Failed to create merged highlight')
|
||||
|
|
@ -266,6 +267,7 @@ export const updateHighlightResolver = authorized<
|
|||
const updated = await updateHighlight(updatedHighlight, {
|
||||
pubsub,
|
||||
uid: claims.uid,
|
||||
refresh: true,
|
||||
})
|
||||
|
||||
if (!updated) {
|
||||
|
|
@ -299,6 +301,7 @@ export const deleteHighlightResolver = authorized<
|
|||
const deleted = await deleteHighlight(highlightId, {
|
||||
pubsub,
|
||||
uid: claims.uid,
|
||||
refresh: true,
|
||||
})
|
||||
|
||||
if (!deleted) {
|
||||
|
|
@ -358,6 +361,7 @@ export const setShareHighlightResolver = authorized<
|
|||
const updated = await updateHighlight(updatedHighlight, {
|
||||
pubsub,
|
||||
uid: claims.uid,
|
||||
refresh: true,
|
||||
})
|
||||
|
||||
if (!updated) {
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ export const deleteLabelResolver = authorized<
|
|||
await deleteLabel(label.name, {
|
||||
pubsub: createPubSubClient(),
|
||||
uid,
|
||||
refresh: true,
|
||||
})
|
||||
|
||||
analytics.track({
|
||||
|
|
@ -248,6 +249,7 @@ export const setLabelsResolver = authorized<
|
|||
{
|
||||
pubsub,
|
||||
uid,
|
||||
refresh: true,
|
||||
},
|
||||
labelsToAdd
|
||||
)
|
||||
|
|
@ -340,6 +342,7 @@ export const updateLabelResolver = authorized<
|
|||
await updateLabel(label, {
|
||||
pubsub,
|
||||
uid,
|
||||
refresh: true,
|
||||
})
|
||||
|
||||
return { label }
|
||||
|
|
@ -391,6 +394,7 @@ export const setLabelsForHighlightResolver = authorized<
|
|||
const updated = await setLabelsForHighlight(highlightId, labels, {
|
||||
pubsub,
|
||||
uid,
|
||||
refresh: true,
|
||||
})
|
||||
if (!updated) {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,11 @@ export const updatePageResolver = authorized<
|
|||
image: input.previewImage ?? undefined,
|
||||
}
|
||||
|
||||
const updateResult = await updatePage(input.pageId, pageData, { ...ctx, uid })
|
||||
const updateResult = await updatePage(input.pageId, pageData, {
|
||||
pubsub: ctx.pubsub,
|
||||
uid,
|
||||
refresh: true,
|
||||
})
|
||||
if (!updateResult) return { errorCodes: [UpdatePageErrorCode.UpdateFailed] }
|
||||
|
||||
const updatedPage = (await getPageById(input.pageId)) as unknown as Page
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ export const createPageSaveRequest = async ({
|
|||
const ctx = {
|
||||
pubsub,
|
||||
uid: userId,
|
||||
refresh: true,
|
||||
}
|
||||
let page = await getPageByParam({
|
||||
userId,
|
||||
|
|
|
|||
Loading…
Reference in a new issue