Commit 2793783 1 parent 17ded50 commit 2793783 Copy full SHA for 2793783
File tree 1 file changed +8
-5
lines changed
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
16
16
limit ,
17
17
orderBy ,
18
18
query ,
19
+ QueryConstraint ,
19
20
setDoc ,
20
21
startAfter ,
21
22
Timestamp ,
@@ -163,13 +164,15 @@ export class ArticleService {
163
164
articles : Article [ ] ;
164
165
lastArticle : Article ;
165
166
} > {
166
- const articlesQuery = query (
167
- this . articlesCollection ,
167
+ const queryOperator : QueryConstraint [ ] = [
168
168
where ( 'uid' , '==' , uid ) ,
169
- lastArticle ? startAfter ( lastArticle . updatedAt ) : null ,
170
169
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 ) ;
173
176
const articles$ = collectionData < Article > ( articlesQuery ) ;
174
177
return articles$ . pipe (
175
178
map ( ( articles ) => {
You can’t perform that action at this time.
0 commit comments