File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
feature/detail/src/main/kotlin/com/ninecraft/booket/feature/detail/book Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,13 @@ class BookDetailPresenter @AssistedInject constructor(
150150 readingRecords = if (startIndex == START_INDEX ) {
151151 result.content.toPersistentList()
152152 } else {
153- (readingRecords + result.content).toPersistentList()
153+ // 새로운 데이터를 기존 리스트와 합친 후 정렬
154+ (readingRecords + result.content).sortedWith(
155+ when (currentRecordSort) {
156+ RecordSort .PAGE_NUMBER_ASC -> compareBy { it.pageNumber }
157+ RecordSort .CREATED_DATE_DESC -> compareByDescending { it.createdAt }
158+ }
159+ ).toPersistentList()
154160 }
155161
156162 currentStartIndex = startIndex
@@ -219,6 +225,12 @@ class BookDetailPresenter @AssistedInject constructor(
219225
220226 is BookDetailUiEvent .OnRecordSortItemSelected -> {
221227 currentRecordSort = event.sortType
228+ readingRecords = readingRecords.sortedWith(
229+ when (event.sortType) {
230+ RecordSort .PAGE_NUMBER_ASC -> compareBy { it.pageNumber }
231+ RecordSort .CREATED_DATE_DESC -> compareByDescending { it.createdAt }
232+ }
233+ ).toPersistentList()
222234 isRecordSortBottomSheetVisible = false
223235 }
224236
You can’t perform that action at this time.
0 commit comments