Local images proxy replace
This commit is contained in:
@ -49,15 +49,49 @@ const UIMiddleware = (function(){
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'MOPIDY_ALBUM_LOADED':
|
||||
case 'SPOTIFY_ALBUM_LOADED':
|
||||
if (action.data) ReactGA.event({ category: 'Album', action: 'Load', label: action.data.uri })
|
||||
case 'ALBUM_LOADED':
|
||||
if (action.data) ReactGA.event({ category: 'Album', action: 'Load', label: action.album.uri })
|
||||
|
||||
// make sure our images use mopidy host:port
|
||||
if (action.album.images && action.album.images.length > 0){
|
||||
var images = Object.assign([], action.album.images)
|
||||
for (var i = 0; i < images.length; i++){
|
||||
if (typeof(images[i]) === 'string' && images[i].startsWith('/images/')){
|
||||
images[i] = '//'+store.getState().mopidy.host+':'+store.getState().mopidy.port+images[i]
|
||||
}
|
||||
}
|
||||
action.album.images = images
|
||||
}
|
||||
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'MOPIDY_ARTIST_LOADED':
|
||||
case 'SPOTIFY_ARTIST_LOADED':
|
||||
if (action.data) ReactGA.event({ category: 'Artist', action: 'Load', label: action.data.uri })
|
||||
case 'ALBUMS_LOADED':
|
||||
if (action.data) ReactGA.event({ category: 'Albums', action: 'Load', label: action.albums.length+' items' })
|
||||
|
||||
for (var i = 0; i < action.albums.length; i++){
|
||||
// make sure our images use mopidy host:port
|
||||
if (action.albums[i].images && action.albums[i].images.length > 0){
|
||||
var images = Object.assign([], action.albums[i].images)
|
||||
for (var j = 0; j < images.length; j++){
|
||||
if (typeof(images[j]) === 'string' && images[j].startsWith('/images/')){
|
||||
images[j] = '//'+store.getState().mopidy.host+':'+store.getState().mopidy.port+images[j]
|
||||
}
|
||||
}
|
||||
action.albums[i].images = images
|
||||
}
|
||||
}
|
||||
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'PLAYLIST_LOADED':
|
||||
if (action.data) ReactGA.event({ category: 'Playlist', action: 'Load', label: action.playlist.uri })
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'ARTIST_LOADED':
|
||||
if (action.data) ReactGA.event({ category: 'Artist', action: 'Load', label: action.artist.uri })
|
||||
next(action)
|
||||
break
|
||||
|
||||
@ -71,12 +105,6 @@ const UIMiddleware = (function(){
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'MOPIDY_PLAYLIST_LOADED':
|
||||
case 'SPOTIFY_PLAYLIST_LOADED':
|
||||
if (action.data) ReactGA.event({ category: 'Playlist', action: 'Load', label: action.data.uri })
|
||||
next(action)
|
||||
break
|
||||
|
||||
case 'MOPIDY_SAVE_PLAYLIST':
|
||||
case 'SPOTIFY_SAVE_PLAYLIST':
|
||||
ReactGA.event({ category: 'Playlist', action: 'Save', label: action.key })
|
||||
|
||||
Reference in New Issue
Block a user