Skip to content

Commit

Permalink
Merge pull request #22 from piashcse/fixing-fav-ui-updates
Browse files Browse the repository at this point in the history
- Fixing deleting fav not reflecting ui immediately
  • Loading branch information
piashcse authored Nov 17, 2024
2 parents 470f3bb + 09750fc commit 2d5cdff
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -77,6 +78,9 @@ fun FavoriteMovieItemView(
viewModel: FavoriteMovieViewModel,
) {
val openDialog = remember { mutableStateOf(false) }
SideEffect {
viewModel.favoriteMoviesFromDB()
}
Column(modifier = Modifier.padding(start = 5.dp, end = 5.dp, top = 0.dp, bottom = 10.dp).cornerRadius(10)) {
Box {
CoilImage(
Expand Down Expand Up @@ -140,7 +144,6 @@ fun FavoriteMovieItemView(
},
{
viewModel.removeMovieFromDB(item.id)
viewModel.favoriteMoviesFromDB()
openDialog.value = false
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -74,6 +75,9 @@ fun FavoriteTvSeries(navController: NavController) {
@Composable
fun FavoriteTvSeriesItemView(item: TvSeriesDetail, navController: NavController, viewModel: FavoriteTvSeriesViewModel) {
val openDialog = remember { mutableStateOf(false) }
SideEffect {
viewModel.favoriteTvSeriesFromDB()
}
Column(modifier = Modifier.padding(start = 5.dp, end = 5.dp, top = 0.dp, bottom = 10.dp).cornerRadius(10)) {
Box {
CoilImage(
Expand Down Expand Up @@ -137,7 +141,6 @@ fun FavoriteTvSeriesItemView(item: TvSeriesDetail, navController: NavController,
},
{
viewModel.removeTvSeriesFromDB(item.id)
viewModel.favoriteTvSeriesFromDB()
openDialog.value = false
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fun MovieDetail(navController: NavController, movieId: Int) {
.clip(CircleShape)
.background(Color.White.copy(alpha = 0.8f))
) {
movieFromDb?.let { detail ->
movieFromDb?.let {
Icon(
imageVector = Icons.Filled.Favorite,
contentDescription = "Favorite",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fun TvSeriesDetail(navController: NavController, tvSeriesId: Int) {
.clip(CircleShape)
.background(Color.White.copy(alpha = 0.8f))
) {
tvSeriesFromDb?.let { detail ->
tvSeriesFromDb?.let {
Icon(
imageVector = Icons.Filled.Favorite,
contentDescription = "Favorite",
Expand Down

0 comments on commit 2d5cdff

Please sign in to comment.