Skip to content

Commit 1ae4bbd

Browse files
committed
✨ 내가 쓴 글 불러오기 기능 추가(정렬 X)
1 parent 8c81f61 commit 1ae4bbd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

data/src/main/java/com/whyranoid/data/post/MyPostPagingDataSource.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ package com.whyranoid.data.post
33
import androidx.paging.PagingSource
44
import androidx.paging.PagingState
55
import com.google.firebase.firestore.FirebaseFirestore
6-
import com.google.firebase.firestore.Query
76
import com.google.firebase.firestore.QuerySnapshot
87
import com.whyranoid.data.constant.CollectionId
98
import com.whyranoid.data.constant.FieldId
10-
import com.whyranoid.data.constant.FieldId.UPDATED_AT
9+
import com.whyranoid.data.constant.FieldId.AUTHOR_ID
1110
import com.whyranoid.data.model.GroupInfoResponse
1211
import com.whyranoid.data.model.RecruitPostResponse
1312
import com.whyranoid.data.model.RunningPostResponse
@@ -37,9 +36,10 @@ class MyPostPagingDataSource @Inject constructor(
3736
override suspend fun load(params: LoadParams<QuerySnapshot>): LoadResult<QuerySnapshot, Post> {
3837
return try {
3938
val postList = mutableListOf<Post>()
39+
4040
// 현재 페이지
4141
val currentPage = params.key ?: db.collection(CollectionId.POST_COLLECTION)
42-
.orderBy(UPDATED_AT, Query.Direction.DESCENDING)
42+
.whereEqualTo(AUTHOR_ID, myUid)
4343
.limit(10)
4444
.get()
4545
.await()
@@ -120,8 +120,9 @@ class MyPostPagingDataSource @Inject constructor(
120120

121121
// 마지막 스냅샷 이후 페이지 불러오기
122122
val nextPage = db.collection(CollectionId.POST_COLLECTION)
123-
.orderBy(UPDATED_AT, Query.Direction.DESCENDING)
124-
.limit(10).startAfter(lastDocumentSnapshot)
123+
.whereEqualTo(AUTHOR_ID, myUid)
124+
.limit(10)
125+
.startAfter(lastDocumentSnapshot)
125126
.get()
126127
.await()
127128

0 commit comments

Comments
 (0)