mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Fix some crashes due to bad UI state (#617)
## Description Fixes two possible crashes: - When saving view options for a favorite page tab - When there are no results on a grid page/tab
This commit is contained in:
parent
0958578082
commit
83a543ad7d
4 changed files with 203 additions and 186 deletions
|
|
@ -169,6 +169,7 @@ class CollectionFolderViewModel
|
|||
context.getString(R.string.error_loading_collection, itemId),
|
||||
) + Dispatchers.IO,
|
||||
) {
|
||||
super.itemId = itemId
|
||||
itemId.toUUIDOrNull()?.let {
|
||||
fetchItem(it)
|
||||
}
|
||||
|
|
@ -206,7 +207,7 @@ class CollectionFolderViewModel
|
|||
) {
|
||||
if (collectionFilter.useSavedLibraryDisplayInfo) {
|
||||
serverRepository.currentUser.value?.let { user ->
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launchIO {
|
||||
val libraryDisplayInfo =
|
||||
LibraryDisplayInfo(
|
||||
userId = user.rowId,
|
||||
|
|
|
|||
|
|
@ -196,6 +196,19 @@ fun <T : CardGridItem> CardGrid(
|
|||
}
|
||||
}
|
||||
|
||||
if (pager.isEmpty()) {
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = modifier.fillMaxSize(),
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.no_results),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
var longPressing by remember { mutableStateOf(false) }
|
||||
Row(
|
||||
// horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
|
|
@ -403,6 +416,7 @@ fun <T : CardGridItem> CardGrid(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun JumpButtons(
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ abstract class ItemViewModel(
|
|||
) : ViewModel() {
|
||||
val item = MutableLiveData<BaseItem?>(null)
|
||||
lateinit var itemId: String
|
||||
lateinit var itemUuid: UUID
|
||||
var itemUuid: UUID? = null
|
||||
|
||||
suspend fun fetchItem(itemId: UUID): BaseItem =
|
||||
withContext(Dispatchers.IO) {
|
||||
|
|
|
|||
|
|
@ -155,8 +155,10 @@ class PersonViewModel
|
|||
|
||||
fun setFavorite(favorite: Boolean) {
|
||||
viewModelScope.launchIO {
|
||||
favoriteWatchManager.setFavorite(itemUuid, favorite)
|
||||
fetchAndSetItem(itemUuid)
|
||||
itemUuid?.let {
|
||||
favoriteWatchManager.setFavorite(it, favorite)
|
||||
fetchAndSetItem(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue