Skip to content

Commit

Permalink
Merge pull request #281 from SwEnt-Group13/fix/home-sort-event
Browse files Browse the repository at this point in the history
Fix/home sort event
  • Loading branch information
Redd87 authored Dec 9, 2024
2 parents ac309d0 + 485321e commit 4bd1423
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 10 additions & 2 deletions app/src/main/java/com/android/unio/ui/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,18 @@ fun HomeContent(
Text(context.getString(R.string.explore_search_no_results))
}
} else {
EventList(navigationAction, searchResults, userViewModel, eventViewModel)
EventList(
navigationAction,
searchResults.sortedWith(compareBy({ it.startDate }, { it.uid })),
userViewModel,
eventViewModel)
}
} else if (events.isNotEmpty()) {
EventList(navigationAction, events, userViewModel, eventViewModel)
EventList(
navigationAction,
events.sortedWith(compareBy({ it.startDate }, { it.uid })),
userViewModel,
eventViewModel)
} else {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Text(
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/com/android/unio/ui/saved/Saved.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ fun SavedScreen(
}

val allEvents by eventViewModel.events.collectAsState()
val savedEvents by derivedStateOf { allEvents.filter { user!!.savedEvents.contains(it.uid) } }
val savedEvents by derivedStateOf {
allEvents
.filter { user!!.savedEvents.contains(it.uid) }
.sortedWith(compareBy({ it.startDate }, { it.uid }))
}

val context = LocalContext.current

Expand Down

0 comments on commit 4bd1423

Please sign in to comment.