Skip to content

Commit

Permalink
fix: getMyArticles (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
komura-c authored Nov 3, 2024
1 parent 17ded50 commit 06021c5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/app/services/article.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
limit,
orderBy,
query,
QueryConstraint,
setDoc,
startAfter,
Timestamp,
Expand Down Expand Up @@ -163,13 +164,15 @@ export class ArticleService {
articles: Article[];
lastArticle: Article;
}> {
const articlesQuery = query(
this.articlesCollection,
const queryOperator: QueryConstraint[] = [
where('uid', '==', uid),
lastArticle ? startAfter(lastArticle.updatedAt) : null,
orderBy('updatedAt', 'desc'),
limit(20)
);
limit(20),
];
if (lastArticle) {
queryOperator.push(startAfter(lastArticle.updatedAt));
}
const articlesQuery = query(this.articlesCollection, ...queryOperator);
const articles$ = collectionData<Article>(articlesQuery);
return articles$.pipe(
map((articles) => {
Expand Down

0 comments on commit 06021c5

Please sign in to comment.