Skip to content

Commit 2793783

Browse files
committed
fix: getMyArticles
1 parent 17ded50 commit 2793783

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/app/services/article.service.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
limit,
1717
orderBy,
1818
query,
19+
QueryConstraint,
1920
setDoc,
2021
startAfter,
2122
Timestamp,
@@ -163,13 +164,15 @@ export class ArticleService {
163164
articles: Article[];
164165
lastArticle: Article;
165166
}> {
166-
const articlesQuery = query(
167-
this.articlesCollection,
167+
const queryOperator: QueryConstraint[] = [
168168
where('uid', '==', uid),
169-
lastArticle ? startAfter(lastArticle.updatedAt) : null,
170169
orderBy('updatedAt', 'desc'),
171-
limit(20)
172-
);
170+
limit(20),
171+
];
172+
if (lastArticle) {
173+
queryOperator.push(startAfter(lastArticle.updatedAt));
174+
}
175+
const articlesQuery = query(this.articlesCollection, ...queryOperator);
173176
const articles$ = collectionData<Article>(articlesQuery);
174177
return articles$.pipe(
175178
map((articles) => {

0 commit comments

Comments
 (0)