mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Dont make queries for readingProgressPercent unless we have to
This commit is contained in:
parent
c4c4a80a6c
commit
a81181ee60
1 changed files with 20 additions and 2 deletions
|
|
@ -383,8 +383,26 @@ 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