Headings on responsive (flex); GridItem trigger image load

This commit is contained in:
James Barnsley
2019-09-15 21:11:57 +12:00
parent 5688b29ae9
commit 6415074287
18 changed files with 197 additions and 76 deletions

View File

@ -25,8 +25,7 @@ const sendRequest = (dispatch, getState, endpoint, params) => new Promise((resol
mode: 'cors',
headers: {
'User-Agent': 'Iris/1.0',
'Authorization': `Discogs key=${key}, secret=${secret}`,
'X-Cache': 'true',
'Authorization': `Discogs key=${key}, secret=${secret}`
},
};

View File

@ -2111,7 +2111,11 @@ const MopidyMiddleware = (function () {
const existing_artist = store.getState().core.artists[artist.uri];
if (existing_artist) {
if (!existing_artist.images) {
store.dispatch(discogsActions.getArtistImages(artist.uri, artist));
if (store.getState().spotify.access_token) {
store.dispatch(spotifyActions.getArtistImages(artist));
} else {
store.dispatch(discogsActions.getArtistImages(artist.uri, artist));
}
}
// Get biography and other stats from LastFM

View File

@ -1177,6 +1177,29 @@ export function getArtists(uris) {
};
}
// Used to get images for non-Spotify artists
export function getArtistImages(artist) {
return (dispatch, getState) => {
request(dispatch, getState, `search?q=${artist.name}&type=artist`)
.then(response => {
if (response.artists.items) {
const updatedArtist = {
uri: artist.uri,
images: response.artists.items[0].images,
}
dispatch(coreActions.artistLoaded(updatedArtist));
}
},
error => {
dispatch(coreActions.handleException(
'Could not load artists',
error,
));
},
);
};
}
export function playArtistTopTracks(uri) {
return (dispatch, getState) => {