Assign keys for global search rows based on source

Maybe fixes #8924

(cherry picked from commit e468554fd9fbe19bfe58b4c018bd8ee87388bed7)
This commit is contained in:
arkon 2023-01-15 10:14:28 -05:00 committed by Jobobby04
parent 767d1b3f20
commit dc661a252a
2 changed files with 8 additions and 8 deletions

View File

@ -71,16 +71,13 @@ fun GlobalSearchContent(
contentPadding = contentPadding, contentPadding = contentPadding,
) { ) {
items.forEach { (source, result) -> items.forEach { (source, result) ->
item { item(key = source.id) {
GlobalSearchResultItem( GlobalSearchResultItem(
title = source.name, title = source.name,
subtitle = LocaleHelper.getDisplayName(source.lang), subtitle = LocaleHelper.getDisplayName(source.lang),
onClick = { onClickSource(source) }, onClick = { onClickSource(source) },
) { ) {
when (result) { when (result) {
is SearchItemResult.Error -> {
GlobalSearchErrorResultItem(message = result.throwable.message)
}
SearchItemResult.Loading -> { SearchItemResult.Loading -> {
GlobalSearchLoadingResultItem() GlobalSearchLoadingResultItem()
} }
@ -104,6 +101,9 @@ fun GlobalSearchContent(
onLongClick = onLongClickItem, onLongClick = onLongClickItem,
) )
} }
is SearchItemResult.Error -> {
GlobalSearchErrorResultItem(message = result.throwable.message)
}
} }
} }
} }

View File

@ -67,16 +67,13 @@ fun MigrateSearchContent(
contentPadding = contentPadding, contentPadding = contentPadding,
) { ) {
items.forEach { (source, result) -> items.forEach { (source, result) ->
item { item(key = source.id) {
GlobalSearchResultItem( GlobalSearchResultItem(
title = if (source.id == sourceId) "${source.name}" else source.name, title = if (source.id == sourceId) "${source.name}" else source.name,
subtitle = LocaleHelper.getDisplayName(source.lang), subtitle = LocaleHelper.getDisplayName(source.lang),
onClick = { onClickSource(source) }, onClick = { onClickSource(source) },
) { ) {
when (result) { when (result) {
is SearchItemResult.Error -> {
GlobalSearchErrorResultItem(message = result.throwable.message)
}
SearchItemResult.Loading -> { SearchItemResult.Loading -> {
GlobalSearchLoadingResultItem() GlobalSearchLoadingResultItem()
} }
@ -93,6 +90,9 @@ fun MigrateSearchContent(
onLongClick = onLongClickItem, onLongClick = onLongClickItem,
) )
} }
is SearchItemResult.Error -> {
GlobalSearchErrorResultItem(message = result.throwable.message)
}
} }
} }
} }