mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Return 0 if looking up page reading progress fails
This commit is contained in:
parent
27143cbedf
commit
dc27c0c7a4
1 changed files with 32 additions and 0 deletions
|
|
@ -386,6 +386,38 @@ export const functionResolvers = {
|
|||
? ContentReader.Pdf
|
||||
: ContentReader.Web
|
||||
},
|
||||
async readingProgressPercent(
|
||||
article: { id: string; readingProgressPercent?: number },
|
||||
_: unknown,
|
||||
ctx: WithDataSourcesContext & { claims: Claims }
|
||||
) {
|
||||
// != used here to check for null or undefined
|
||||
if (article.readingProgressPercent != null) {
|
||||
return article.readingProgressPercent
|
||||
}
|
||||
return (
|
||||
await getPageByParam({
|
||||
userId: ctx.claims.uid,
|
||||
_id: article.id,
|
||||
})
|
||||
)?.readingProgressPercent || 0
|
||||
},
|
||||
async readingProgressAnchorIndex(
|
||||
article: { id: string; readingProgressAnchorIndex?: number },
|
||||
_: unknown,
|
||||
ctx: WithDataSourcesContext & { claims: Claims }
|
||||
) {
|
||||
// != used here to check for null or undefined
|
||||
if (article.readingProgressAnchorIndex != null) {
|
||||
return article.readingProgressAnchorIndex
|
||||
}
|
||||
return (
|
||||
await getPageByParam({
|
||||
userId: ctx.claims.uid,
|
||||
_id: article.id,
|
||||
})
|
||||
)?.readingProgressAnchorIndex || 0
|
||||
},
|
||||
async highlights(
|
||||
article: { id: string; userId?: string },
|
||||
_: { input: ArticleHighlightsInput },
|
||||
|
|
|
|||
Loading…
Reference in a new issue