Skip to content

Commit a07eb92

Browse files
authored
[DPMBE-114] 약속 정렬 순서를 오래된 순으로 변경한다 (#184)
* feat : 예정된 약속 정렬 순서 변경 * refactor: spotless
1 parent ca880bd commit a07eb92

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/promise/usecase/PromiseReadUseCase.kt

+8-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ class PromiseReadUseCase(
6969
}
7070

7171
val action: (Entry<PromiseType, MutableList<PromiseFindDto>>) -> Unit = { (promiseType, promiseFindDtos) ->
72-
promiseFindDtos.sortBy { it.endTime }
72+
// promiseType == BEFORE 인 것만 정렬
73+
when (promiseType) {
74+
// 예정된 약속은 오름차순 정렬
75+
PromiseType.BEFORE -> promiseFindDtos.sortBy { it.endTime }
76+
// 종료된 약속은 내림차순 정렬
77+
else -> promiseFindDtos.sortByDescending { it.endTime }
78+
}
7379
}
7480
promiseSplitByPromiseTypeDto.forEach(action)
7581
}
@@ -119,7 +125,7 @@ class PromiseReadUseCase(
119125
}
120126

121127
val promiseImagesUrls = promiseImageAdapter.findAllByPromiseId(promise.id!!)
122-
.sortedByDescending { it.createdAt }
128+
.sortedBy { it.createdAt }
123129
.map { it.uri }
124130

125131
val timeOverLocations = promiseUsers.mapNotNull { promiseUser ->

0 commit comments

Comments
 (0)