Skip to content

Commit 9b44b0d

Browse files
committed
show suggestions for multiple multitasked activities
1 parent 9d16609 commit 9b44b0d

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

domain/src/main/java/com/example/util/simpletimetracker/domain/activitySuggestion/interactor/GetCurrentActivitySuggestionsInteractor.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ class GetCurrentActivitySuggestionsInteractor @Inject constructor(
3636
private suspend fun execute(
3737
runningRecords: List<RunningRecord>,
3838
): Set<Long> {
39-
val currentOrLast = runningRecords.minByOrNull { it.timeStarted }
40-
?: recordInteractor.getAllPrev(System.currentTimeMillis()).firstOrNull()
39+
val currentOrLast = runningRecords.takeIf { it.isNotEmpty() }
40+
?: recordInteractor.getAllPrev(System.currentTimeMillis())
4141

42-
val currentOrLastTypeId = currentOrLast?.typeIds?.firstOrNull()
42+
val currentOrLastTypeIds = currentOrLast.mapNotNull { it.typeIds.firstOrNull() }
4343

44-
return currentOrLastTypeId
45-
?.let { activitySuggestionInteractor.getByTypeId(it) }
46-
?.firstOrNull()
47-
?.suggestionIds
48-
.orEmpty()
44+
return currentOrLastTypeIds
45+
.mapNotNull {
46+
activitySuggestionInteractor.getByTypeId(it).firstOrNull()?.suggestionIds
47+
}
48+
.flatten()
4949
.toSet()
5050
}
5151
}

0 commit comments

Comments
 (0)