diff --git a/packages/api/src/resolvers/function_resolvers.ts b/packages/api/src/resolvers/function_resolvers.ts index 1ee95e46c..c53fce576 100644 --- a/packages/api/src/resolvers/function_resolvers.ts +++ b/packages/api/src/resolvers/function_resolvers.ts @@ -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 },