Skip to content

Commit c845429

Browse files
committed
♻️ 페이징당 데이터의 개수 상부로 분리
1 parent 1ae4bbd commit c845429

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class MyPostPagingDataSource @Inject constructor(
4040
// 현재 페이지
4141
val currentPage = params.key ?: db.collection(CollectionId.POST_COLLECTION)
4242
.whereEqualTo(AUTHOR_ID, myUid)
43-
.limit(10)
43+
.limit(DATA_COUNT_PER_PAGE)
4444
.get()
4545
.await()
4646

@@ -121,7 +121,7 @@ class MyPostPagingDataSource @Inject constructor(
121121
// 마지막 스냅샷 이후 페이지 불러오기
122122
val nextPage = db.collection(CollectionId.POST_COLLECTION)
123123
.whereEqualTo(AUTHOR_ID, myUid)
124-
.limit(10)
124+
.limit(DATA_COUNT_PER_PAGE)
125125
.startAfter(lastDocumentSnapshot)
126126
.get()
127127
.await()
@@ -139,4 +139,8 @@ class MyPostPagingDataSource @Inject constructor(
139139
fun setMyUid(myUid: String) {
140140
this.myUid = myUid
141141
}
142+
143+
companion object {
144+
private const val DATA_COUNT_PER_PAGE = 10L
145+
}
142146
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class PostPagingDataSource @Inject constructor(
3939
// 현재 페이지
4040
val currentPage = params.key ?: db.collection(POST_COLLECTION)
4141
.orderBy(UPDATED_AT, Query.Direction.DESCENDING)
42-
.limit(10)
42+
.limit(DATA_COUNT_PER_PAGE)
4343
.get()
4444
.await()
4545

@@ -120,7 +120,7 @@ class PostPagingDataSource @Inject constructor(
120120
// 마지막 스냅샷 이후 페이지 불러오기
121121
val nextPage = db.collection(POST_COLLECTION)
122122
.orderBy(UPDATED_AT, Query.Direction.DESCENDING)
123-
.limit(10).startAfter(lastDocumentSnapshot)
123+
.limit(DATA_COUNT_PER_PAGE).startAfter(lastDocumentSnapshot)
124124
.get()
125125
.await()
126126

@@ -133,4 +133,8 @@ class PostPagingDataSource @Inject constructor(
133133
LoadResult.Error(e)
134134
}
135135
}
136+
137+
companion object {
138+
private const val DATA_COUNT_PER_PAGE = 10L
139+
}
136140
}

0 commit comments

Comments
 (0)