Files
Iris/src/js/services/google/reducer.js

35 lines
993 B
JavaScript
Raw Normal View History

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;
}
}