Skip to content

Commit

Permalink
Review comments: Fix favorite deselection, update favorits in onResume
Browse files Browse the repository at this point in the history
  • Loading branch information
dshokouhi committed Nov 19, 2021
1 parent 8e67151 commit 7f0b2eb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Expand Up @@ -78,7 +78,7 @@ fun LoadWearFavoritesSettings(
.padding(15.dp)
.clickable {
onEntitySelected(
isFavoriteSelected(index),
false,
favoritesList[index],
activity
)
Expand Down
Expand Up @@ -43,6 +43,11 @@ class HomeActivity : ComponentActivity(), HomeView {
mainViewModel.init(presenter)
}

override fun onResume() {
mainViewModel.updateFavorites()
super.onResume()
}

override fun onDestroy() {
presenter.onFinish()
super.onDestroy()
Expand Down
Expand Up @@ -81,6 +81,14 @@ class MainViewModel @Inject constructor() : ViewModel() {
}
}

// TODO: Remove the below as we should save favorites to the DB so we can use a proper flow like above
fun updateFavorites() {
viewModelScope.launch {
favoriteEntityIds.clear()
favoriteEntityIds.addAll(homePresenter.getWearHomeFavorites())
}
}

fun setTileShortcut(index: Int, entity: SimplifiedEntity) {
viewModelScope.launch {
if (index < shortcutEntities.size) {
Expand Down

0 comments on commit 7f0b2eb

Please sign in to comment.