Change icon and badge stateIn behavior from WhileSubscriped to Lazy
This commit is contained in:
parent
8043d90cb5
commit
92fa92ff50
@ -78,11 +78,11 @@ class SearchableItemVM : ListItemViewModel(), KoinComponent {
|
||||
|
||||
val badge = searchable.flatMapLatest {
|
||||
if (it == null) emptyFlow() else badgeService.getBadge(it)
|
||||
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
|
||||
}.stateIn(viewModelScope, SharingStarted.Lazily, null)
|
||||
|
||||
val icon = searchable.combine(iconSize) { sh, sz -> sh to sz }.flatMapLatest { (s, size) ->
|
||||
if (s == null || size == 0) emptyFlow() else iconService.getIcon(s, size)
|
||||
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
|
||||
}.stateIn(viewModelScope, SharingStarted.Lazily, null)
|
||||
|
||||
val tags = searchable.flatMapLatest {
|
||||
if (it == null) emptyFlow() else tagsService.getTags(it)
|
||||
|
||||
@ -88,7 +88,7 @@ fun GridItem(
|
||||
var bounds by remember { mutableStateOf(Rect.Zero) }
|
||||
|
||||
Column(modifier = modifier, horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
val badge by remember(item.key) { viewModel.badge }.collectAsStateWithLifecycle()
|
||||
val badge by viewModel.badge.collectAsStateWithLifecycle()
|
||||
val icon by viewModel.icon.collectAsStateWithLifecycle()
|
||||
|
||||
val launchOnPress = !item.preferDetailsOverLaunch
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user