Skip to content

Commit c8f502f

Browse files
committed
✨ 게시글을 시간순으로 정렬하여 보여주도록 수정
1 parent a58408e commit c8f502f

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

presentation/src/main/java/com/whyranoid/presentation/community/CommunityItemFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ internal class CommunityItemFragment :
6262

6363
private fun handleEvent(event: Event) {
6464
when (event) {
65-
is Event.CategoryItemClick -> {
65+
is Event.GroupItemClick -> {
6666
val action =
6767
CommunityFragmentDirections.actionCommunityFragmentToGroupDetailFragment(event.groupInfo)
6868
findNavController().navigate(action)

presentation/src/main/java/com/whyranoid/presentation/community/CommunityViewModel.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class CommunityViewModel @Inject constructor(
4040
get() = _eventFlow.asSharedFlow()
4141

4242
fun onCategoryItemClicked(groupInfo: GroupInfoUiModel) {
43-
emitEvent(Event.CategoryItemClick(groupInfo))
43+
emitEvent(Event.GroupItemClick(groupInfo))
4444
}
4545

4646
private fun emitEvent(event: Event) {
@@ -59,7 +59,9 @@ class CommunityViewModel @Inject constructor(
5959
}
6060

6161
getPostsUseCase().onEach { postList ->
62-
_postList.value = postList
62+
_postList.value = postList.sortedByDescending { post ->
63+
post.updatedAt
64+
}
6365
}.launchIn(viewModelScope)
6466
}
6567
}

presentation/src/main/java/com/whyranoid/presentation/community/Event.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ package com.whyranoid.presentation.community
33
import com.whyranoid.presentation.model.GroupInfoUiModel
44

55
sealed class Event {
6-
data class CategoryItemClick(val groupInfo: GroupInfoUiModel) : Event()
6+
data class GroupItemClick(val groupInfo: GroupInfoUiModel) : Event()
7+
// data class CategoryItemClick(val groupInfo: GroupInfoUiModel) : Event()
78
}

0 commit comments

Comments
 (0)