mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #235 from omnivore-app/fix/reading-progress-lookup
Dont make queries for readingProgressPercent unless we have to
This commit is contained in:
commit
388bbde064
1 changed files with 24 additions and 2 deletions
|
|
@ -383,8 +383,30 @@ export const functionResolvers = {
|
|||
? ContentReader.Pdf
|
||||
: ContentReader.Web
|
||||
},
|
||||
readingProgressPercent: getReadingProgressForArticleResolver,
|
||||
readingProgressAnchorIndex: getReadingProgressAnchorIndexForArticleResolver,
|
||||
async readingProgressPercent(
|
||||
article: { id: string; articleReadingProgress?: number },
|
||||
_: unknown,
|
||||
ctx: WithDataSourcesContext & { claims: Claims }
|
||||
) {
|
||||
if ('articleReadingProgress' in article) {
|
||||
return article.articleReadingProgress
|
||||
}
|
||||
return (
|
||||
await ctx.models.userArticle.getByArticleId(ctx.claims.uid, article.id)
|
||||
)?.articleReadingProgress
|
||||
},
|
||||
async readingProgressAnchorIndex(
|
||||
article: { id: string; articleReadingProgressAnchorIndex?: number },
|
||||
_: unknown,
|
||||
ctx: WithDataSourcesContext & { claims: Claims }
|
||||
) {
|
||||
if ('articleReadingProgressAnchorIndex' in article) {
|
||||
return article.articleReadingProgressAnchorIndex
|
||||
}
|
||||
return (
|
||||
await ctx.models.userArticle.getByArticleId(ctx.claims.uid, article.id)
|
||||
)?.articleReadingProgressAnchorIndex
|
||||
},
|
||||
async highlights(
|
||||
article: { id: string; userId?: string },
|
||||
_: { input: ArticleHighlightsInput },
|
||||
|
|
|
|||
Loading…
Reference in a new issue