Move code into coroutines

This commit is contained in:
Damontecres 2026-01-30 10:30:39 -05:00
parent 8437ddb51d
commit bec833b0e8
No known key found for this signature in database

View file

@ -176,6 +176,7 @@ class HomeSettingsViewModel
} }
fun deleteRow(index: Int) { fun deleteRow(index: Int) {
viewModelScope.launchIO {
updateState { updateState {
val rows = it.rows.toMutableList().apply { removeAt(index) } val rows = it.rows.toMutableList().apply { removeAt(index) }
val rowData = it.rowData.toMutableList().apply { removeAt(index) } val rowData = it.rowData.toMutableList().apply { removeAt(index) }
@ -185,6 +186,7 @@ class HomeSettingsViewModel
) )
} }
} }
}
fun addRow(type: MetaRowType): Job = fun addRow(type: MetaRowType): Job =
viewModelScope.launchIO { viewModelScope.launchIO {
@ -341,6 +343,7 @@ class HomeSettingsViewModel
} }
fun updateViewOptionsForAll(viewOptions: HomeRowViewOptions) { fun updateViewOptionsForAll(viewOptions: HomeRowViewOptions) {
viewModelScope.launchIO {
updateState { updateState {
it.copy( it.copy(
rowData = rowData =
@ -354,6 +357,7 @@ class HomeSettingsViewModel
) )
} }
} }
}
fun saveToRemote() { fun saveToRemote() {
viewModelScope.launchIO { viewModelScope.launchIO {
@ -456,6 +460,7 @@ class HomeSettingsViewModel
} }
fun resizeCards(relative: Int) { fun resizeCards(relative: Int) {
viewModelScope.launchIO {
updateState { updateState {
val newRows = val newRows =
it.rows.toMutableList().map { row -> it.rows.toMutableList().map { row ->
@ -477,6 +482,7 @@ class HomeSettingsViewModel
} }
} }
} }
}
data class HomePageSettingsState( data class HomePageSettingsState(
val loading: LoadingState, val loading: LoadingState,