Skip to content

Commit

Permalink
Fix Favourites Crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Iamlooker committed Aug 19, 2023
1 parent c3d8472 commit ccc3359
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class FavouriteFragmentAdapter(
override fun getItemCount(): Int = apps.size

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val item = apps[position].firstOrNull()?.item() ?: return
val item = apps[position].first().item()
val repository: Repository? = repositories[item.repositoryId]
holder.name.text = item.name
holder.summary.isVisible = item.summary.isNotEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import javax.inject.Inject


@HiltViewModel
class FavouritesViewModel @Inject constructor(
private val userPreferencesRepository: UserPreferencesRepository
Expand All @@ -25,8 +24,8 @@ class FavouritesViewModel @Inject constructor(
userPreferencesRepository.userPreferencesFlow
.distinctMap { it.favouriteApps }
.map { favourites ->
favourites.map { app ->
Database.ProductAdapter.get(app, null)
favourites.mapNotNull { app ->
Database.ProductAdapter.get(app, null).ifEmpty { null }
}
}.asStateFlow(emptyList())

Expand Down

0 comments on commit ccc3359

Please sign in to comment.