File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
Fruitties/shared/src/commonMain/kotlin/com/example/fruitties/viewmodel Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -44,10 +44,7 @@ class CartViewModel(
44
44
val cartUiState: StateFlow <CartUiState > =
45
45
repository.cartDetails
46
46
.map { details ->
47
- CartUiState (
48
- cartDetails = details,
49
- totalItemCount = details.sumOf { it.count },
50
- )
47
+ CartUiState (cartDetails = details)
51
48
}.stateIn(
52
49
scope = viewModelScope,
53
50
started = SharingStarted .WhileSubscribed (TIMEOUT_MILLIS ),
@@ -78,7 +75,8 @@ class CartViewModel(
78
75
*/
79
76
data class CartUiState (
80
77
val cartDetails : List <CartItemDetails > = listOf(),
81
- val totalItemCount : Int = 0 ,
82
- )
78
+ ) {
79
+ val totalItemCount: Int = cartDetails.sumOf { it.count }
80
+ }
83
81
84
82
private const val TIMEOUT_MILLIS = 5_000L
You can’t perform that action at this time.
0 commit comments