Skip to content

Commit

Permalink
Merge pull request nukeop#204 from PaliwalSparsh/feature/FixTagView
Browse files Browse the repository at this point in the history
TagView: Fixes nukeop#191 click on album not working
  • Loading branch information
nukeop authored Jan 30, 2019
2 parents 29f7c30 + 208682b commit b722f33
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
20 changes: 18 additions & 2 deletions app/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,24 @@ export function artistInfoSearchByName (artistName, history) {
};
}

export function albumInfoSearchByName (albumName, history) {
return dispatch => {
discogs
.searchAlbums(albumName)
.then(searchResults => searchResults.json())
.then(searchResultsJson => {
let album = searchResultsJson.results[0];
dispatch(albumInfoSearch(album.id, album.type));
if (history) {
history.push('/album/' + album.id);
}
})
.catch(error => {
logger.error(error);
});
};
}

export function lastFmArtistInfoStart (artistId) {
return {
type: LASTFM_ARTIST_INFO_SEARCH_START,
Expand Down Expand Up @@ -341,5 +359,3 @@ export function lastFmArtistInfoSearch (artist, artistId) {
});
};
}


16 changes: 15 additions & 1 deletion app/components/TagView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class TagView extends React.Component {
this.props.artistInfoSearchByName(artistName, this.props.history);
}

albumInfoSearchByName(albumName) {
this.props.albumInfoSearchByName(albumName, this.props.history);
}

renderTagHeader(tagInfo, topArtists) {
let { tag } = this.props;
return <TagHeader tag={tag} tagInfo={tagInfo} topArtists={topArtists} />;
Expand All @@ -35,6 +39,16 @@ class TagView extends React.Component {
);
}

renderTopAlbums(topAlbums) {
return (
<TagTopList
topList={topAlbums}
onClick={this.albumInfoSearchByName.bind(this)}
header='Top Albums'
/>
);
}

renderTagTopTracks(topTracks, addToQueue, musicSources) {
return (
<TagTopTracks
Expand All @@ -53,7 +67,7 @@ class TagView extends React.Component {
return (
<div className={styles.lists_container}>
{this.renderTopArtists(topArtists)}
<TagTopList topList={topAlbums} header='Top Albums' />
{this.renderTopAlbums(topAlbums)}
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions app/containers/TagViewContainer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class TagViewContainer extends React.Component {
<TagView
loadTagInfo={actions.loadTagInfo}
artistInfoSearchByName={actions.artistInfoSearchByName}
albumInfoSearchByName={actions.albumInfoSearchByName}
history={history}
tag={match.params.tagName}
tags={tags}
Expand Down
5 changes: 5 additions & 0 deletions app/rest/Discogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ function searchQuery (terms, count = 15) {
);
}

function searchAlbums (terms, count = 15) {
return fetch(searchQuery(terms, count) + '&type=albums');
}

function searchArtists (terms, count = 15) {
return fetch(searchQuery(terms, count) + '&type=artist');
}
Expand Down Expand Up @@ -65,6 +69,7 @@ function artistReleases (artistId) {
}

module.exports = {
searchAlbums,
searchArtists,
searchReleases,
releaseInfo,
Expand Down

0 comments on commit b722f33

Please sign in to comment.