2018-10-16 21:21:36 +13:00
|
|
|
|
2018-10-17 21:33:54 +13:00
|
|
|
import * as helpers from '../../helpers';
|
|
|
|
|
|
2018-10-16 21:21:36 +13:00
|
|
|
export default function reducer(google = {}, action){
|
|
|
|
|
switch (action.type){
|
|
|
|
|
|
|
|
|
|
case 'GOOGLE_SET':
|
|
|
|
|
return Object.assign({}, google, action.data);
|
|
|
|
|
|
2018-10-17 21:33:54 +13:00
|
|
|
case 'GOOGLE_LIBRARY_ARTISTS_LOADED':
|
|
|
|
|
if (google.library_artists){
|
|
|
|
|
var uris = [...google.library_artists,...action.uris];
|
|
|
|
|
} else {
|
|
|
|
|
var uris = action.uris;
|
|
|
|
|
}
|
|
|
|
|
return Object.assign({}, google, { library_artists: helpers.removeDuplicates(uris) });
|
|
|
|
|
|
|
|
|
|
case 'GOOGLE_CLEAR_LIBRARY_ARTISTS':
|
|
|
|
|
return Object.assign({}, google, { library_artists: null });
|
|
|
|
|
|
|
|
|
|
case 'GOOGLE_LIBRARY_ALBUMS_LOADED':
|
|
|
|
|
if (google.library_albums){
|
|
|
|
|
var uris = [...google.library_albums,...action.uris];
|
|
|
|
|
} else {
|
|
|
|
|
var uris = action.uris;
|
|
|
|
|
}
|
|
|
|
|
return Object.assign({}, google, { library_albums: helpers.removeDuplicates(uris) });
|
|
|
|
|
|
|
|
|
|
case 'GOOGLE_CLEAR_LIBRARY_ALBUMS':
|
|
|
|
|
return Object.assign({}, google, { library_albums: null });
|
|
|
|
|
|
2018-10-16 21:21:36 +13:00
|
|
|
default:
|
|
|
|
|
return google
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|