Better error handling for errors on home page rows (#1128)
## Description Adds better error handling when loading home page rows. For example, this fixes loading errors if a playlist row is configured, but the playlist is deleted. Also fixes an issue from #1116 where changing users doesn't go the home page. ### Related issues Related to #1124 ### Testing Emulator ## Screenshots N/A ## AI or LLM usage None
This commit is contained in:
parent
dac0b7208c
commit
920733075b
4 changed files with 43 additions and 33 deletions
|
|
@ -122,19 +122,23 @@ class HomeSettingsViewModel
|
|||
state.value
|
||||
.let { state ->
|
||||
state.rows
|
||||
.map { it.config }
|
||||
.map { row ->
|
||||
viewModelScope.async(Dispatchers.IO) {
|
||||
semaphore.withPermit {
|
||||
homeSettingsService.fetchDataForRow(
|
||||
row = row,
|
||||
scope = viewModelScope,
|
||||
prefs = prefs,
|
||||
userDto = userDto,
|
||||
libraries = state.libraries,
|
||||
limit = limit,
|
||||
isRefresh = false,
|
||||
)
|
||||
try {
|
||||
homeSettingsService.fetchDataForRow(
|
||||
row = row.config,
|
||||
scope = viewModelScope,
|
||||
prefs = prefs,
|
||||
userDto = userDto,
|
||||
libraries = state.libraries,
|
||||
limit = limit,
|
||||
isRefresh = false,
|
||||
)
|
||||
} catch (ex: Exception) {
|
||||
Timber.e(ex, "Error on row %s", row)
|
||||
HomeRowLoadingState.Error(row.title, exception = ex)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -195,7 +199,12 @@ class HomeSettingsViewModel
|
|||
viewModelScope.launchIO {
|
||||
updateState {
|
||||
val rows = it.rows.toMutableList().apply { removeAt(index) }
|
||||
val rowData = it.rowData.toMutableList().apply { removeAt(index) }
|
||||
val rowData =
|
||||
if (index in it.rowData.indices) {
|
||||
it.rowData.toMutableList().apply { removeAt(index) }
|
||||
} else {
|
||||
it.rowData
|
||||
}
|
||||
it.copy(
|
||||
rows = rows,
|
||||
rowData = rowData,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue