Proof-of-concept pinned playlist

This commit is contained in:
James Barnsley
2020-08-08 22:17:31 +12:00
parent 7e1d97ed54
commit 55c06454e0
10 changed files with 425 additions and 82 deletions

View File

@ -424,3 +424,24 @@ export function getLibraryArtists() {
type: 'GET_LIBRARY_ARTISTS',
};
}
export function addPinned(uri) {
return {
type: 'ADD_PINNED',
uri,
};
}
export function removePinned(uri) {
return {
type: 'REMOVE_PINNED',
uri,
};
}
export function updatePinned(pinned) {
return {
type: 'UPDATE_PINNED',
pinned,
};
}

View File

@ -807,6 +807,21 @@ const CoreMiddleware = (function () {
next(action);
break;
case 'ADD_PINNED':
store.dispatch(coreActions.updatePinned([
...store.getState().core.pinned,
action.uri,
]));
next(action);
break;
case 'REMOVE_PINNED':
store.dispatch(coreActions.updatePinned(
store.getState().core.pinned.filter((item) => item !== action.uri),
));
next(action);
break;
// This action is irrelevant to us, pass it on to the next middleware
default:
return next(action);

View File

@ -294,6 +294,11 @@ export default function reducer(core = {}, action) {
},
};
case 'UPDATE_PINNED':
return {
...core,
pinned: action.pinned,
};
default:
return core;

View File

@ -221,6 +221,13 @@ const localstorageMiddleware = (function () {
);
break;
case 'UPDATE_PINNED':
storage.set(
'core',
{ pinned: action.pinned },
);
break;
case 'UI_SET':
storage.set(
'ui',