Updating pinned URIs when they change (eg renaming local playlist)
This commit is contained in:
@ -449,3 +449,11 @@ export function updatePinned(pinned) {
|
||||
pinned: removeDuplicates(pinned),
|
||||
};
|
||||
}
|
||||
|
||||
export function updatePinnedUri(oldUri, newUri) {
|
||||
return {
|
||||
type: 'UPDATE_PINNED_URI',
|
||||
oldUri,
|
||||
newUri,
|
||||
};
|
||||
}
|
||||
|
||||
@ -803,6 +803,16 @@ const CoreMiddleware = (function () {
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'UPDATE_PINNED_URI':
|
||||
const pinnedUris = store.getState().core.pinned;
|
||||
const pinnedUriIndex = pinnedUris.indexOf(action.oldUri);
|
||||
if (pinnedUriIndex > -1) {
|
||||
pinnedUris[pinnedUriIndex] = action.newUri;
|
||||
store.dispatch(coreActions.updatePinned(pinnedUris));
|
||||
}
|
||||
next(action);
|
||||
break;
|
||||
|
||||
// This action is irrelevant to us, pass it on to the next middleware
|
||||
default:
|
||||
return next(action);
|
||||
|
||||
Reference in New Issue
Block a user