From d97963a1c0b1cf72ccd2897027f9edaa2d8348be Mon Sep 17 00:00:00 2001 From: asantos Date: Thu, 21 May 2015 22:41:00 +0200 Subject: [PATCH] AlbumDetailScreen.js finished --- AlbumDetailScreen.js | 23 ++++------------------- FavoritesListScreen.js | 2 +- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/AlbumDetailScreen.js b/AlbumDetailScreen.js index 5482a3e..c052e47 100644 --- a/AlbumDetailScreen.js +++ b/AlbumDetailScreen.js @@ -22,22 +22,15 @@ function fullSizeUrl(thumbUrl) { } var AlbumDetailScreen = React.createClass({ - getInitialState() { - return this.computedState(); - }, - computedState() { - return { - isFavorite: FavoritesStore.isFavorite(this.props.album) - } + getInitialState() { + return {}; }, componentDidMount() { // way of calculating relative size: // https://github.com/facebook/react-native/issues/953 setTimeout(this.measureArtworkContainer); - - FavoritesStore.on(FavoritesStore.CHANGE_EVENT, this.onFavoritesChange); }, measureArtworkContainer() { @@ -46,26 +39,18 @@ var AlbumDetailScreen = React.createClass({ }); }, - componentWillUnmount() { - FavoritesStore.removeListener(FavoritesStore.CHANGE_EVENT, this.onFavoritesChange); - }, - - onFavoritesChange() { - this.setState(this.computedState()); - }, - onShowMoreButtonPressed() { LinkingIOS.openURL(this.props.album.collectionViewUrl); }, onFavoriteButtonPressed() { - FavoritesStore.toggleFavorite(this.props.album); + }, render() { var album = this.props.album; var year = yearFromReleaseDate(album.releaseDate); - var favoriteButtonText = this.state.isFavorite ? 'Unfavorite' : 'Favorite'; + var favoriteButtonText = 'Favorite'; var artworkContainerHeight = this.state.artworkContainerHeight; return ( diff --git a/FavoritesListScreen.js b/FavoritesListScreen.js index 7f78f84..22fa392 100644 --- a/FavoritesListScreen.js +++ b/FavoritesListScreen.js @@ -24,7 +24,7 @@ var FavoritesListScreen = React.createClass({ }, componentWillUnmount() { - + }, onFavoritesChange() {