mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 04:39:04 +00:00
Fix
This commit is contained in:
parent
0cf7fc7864
commit
cf5a420cc4
1 changed files with 9 additions and 6 deletions
|
|
@ -27,13 +27,16 @@ class TaskListViewModel @Inject constructor(
|
|||
val taskType = TaskType.from(savedStateHandle.get<String>("task_type"))
|
||||
val tasks = taskRepository.getTasks(taskType ?: TaskType.HABIT)
|
||||
.map {
|
||||
val taskList: MutableList<Any> = it.sortedBy { it.completed }.toMutableList()
|
||||
var firstCompletedIndex = taskList.indexOfFirst { it is Task && it.completed }
|
||||
if (firstCompletedIndex < 0) {
|
||||
firstCompletedIndex = 0
|
||||
if (taskType == TaskType.DAILY || taskType == TaskType.TODO) {
|
||||
val taskList: MutableList<Any> = it.sortedBy { it.completed }.toMutableList()
|
||||
val firstCompletedIndex = taskList.indexOfFirst { it is Task && it.completed }
|
||||
if (firstCompletedIndex >= 0) {
|
||||
taskList.add(firstCompletedIndex, "Done today")
|
||||
}
|
||||
taskList
|
||||
} else {
|
||||
it
|
||||
}
|
||||
taskList.add(firstCompletedIndex, "Done today")
|
||||
taskList
|
||||
}
|
||||
.asLiveData()
|
||||
val user = userRepository.getUser()
|
||||
|
|
|
|||
Loading…
Reference in a new issue