Skip to content

Commit

Permalink
resolved cardoso#18
Browse files Browse the repository at this point in the history
  • Loading branch information
ftp27 committed Oct 6, 2019
1 parent 3e6f3ff commit b66cb71
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions ReduxMovieDB/Controllers/MovieDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ class MovieDetailViewController: UITableViewController {
return defaultHeight
}
@IBAction func toggleFavorite(_ sender: Any) {
guard let id = (sender as? UIButton)?.tag else { return }
guard id >= 0 else { return }
mainStore.dispatch(MainStateAction.toggleFavoriteMovie)
favoriteButton.setTitle(mainStore.state.isCurrentFavorite ? "" : "", for: .normal)
}

func setupPosterView() {
Expand Down
3 changes: 2 additions & 1 deletion ReduxMovieDB/State/MainState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ struct MainState: StateType, Equatable {
var genres: [Genre] = []
var moviePages: Pages<Movie> = Pages<Movie>()
var movieDetail: MovieDetailState = .hide
var favorites: [Movie] { return favoritesStore.favorites }
var isCurrentFavorite: Bool { movieDetail.movie?.id.map(isFavorite) ?? false }
var favorites: [Movie] { favoritesStore.favorites }
var search: SearchState = .canceled
var isFavoritesList: Bool = false

Expand Down

0 comments on commit b66cb71

Please sign in to comment.