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