Upgrading GA; Creating unified Button for all variants
This commit is contained in:
@ -429,10 +429,10 @@ export function getLibraryArtists() {
|
||||
};
|
||||
}
|
||||
|
||||
export function addPinned(uri) {
|
||||
export function addPinned(item) {
|
||||
return {
|
||||
type: 'ADD_PINNED',
|
||||
uri,
|
||||
item,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import React from 'react';
|
||||
import ReactGA from 'react-ga';
|
||||
import { arrayOf } from '../../util/arrays';
|
||||
import URILink from '../../components/URILink';
|
||||
import { uriSource, upgradeSpotifyPlaylistUris, uriType, titleCase } from '../../util/helpers';
|
||||
import { uriSource, upgradeSpotifyPlaylistUris, uriType } from '../../util/helpers';
|
||||
import {
|
||||
formatTracks,
|
||||
formatTrack,
|
||||
@ -791,25 +791,25 @@ const CoreMiddleware = (function () {
|
||||
case 'ADD_PINNED':
|
||||
store.dispatch(coreActions.updatePinned([
|
||||
...store.getState().core.pinned,
|
||||
action.uri,
|
||||
formatSimpleObject(action.item),
|
||||
]));
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'REMOVE_PINNED':
|
||||
store.dispatch(coreActions.updatePinned(
|
||||
store.getState().core.pinned.filter((item) => item !== action.uri),
|
||||
store.getState().core.pinned.filter((pinnedItem) => pinnedItem.uri !== action.uri),
|
||||
));
|
||||
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));
|
||||
}
|
||||
store.dispatch(coreActions.updatePinned(
|
||||
store.getState().core.pinned.map((pinnedItem) => ({
|
||||
...pinnedItem,
|
||||
...(pinnedItem.uri === action.oldUri ? { uri: action.newUri } : {}),
|
||||
})),
|
||||
));
|
||||
next(action);
|
||||
break;
|
||||
|
||||
|
||||
@ -1598,7 +1598,6 @@ const MopidyMiddleware = (function () {
|
||||
* */
|
||||
|
||||
case 'MOPIDY_GET_LIBRARY_PLAYLISTS':
|
||||
console.log(action);
|
||||
request(store, 'playlists.asList')
|
||||
.then((response) => {
|
||||
// drop in our URI list
|
||||
@ -1780,7 +1779,8 @@ const MopidyMiddleware = (function () {
|
||||
// Remove old playlist (by old key/uri) from index
|
||||
// By providing the new key, the old playlist gets replaced with a redirector object
|
||||
store.dispatch(coreActions.removeFromIndex('playlists', action.key, playlist.uri));
|
||||
store.dispatch(coreActions.updatePinnedUri(action.key, playlist.uri));
|
||||
store.dispatch(coreActions.removePinned(action.key));
|
||||
store.dispatch(coreActions.addPinned(playlist));
|
||||
}
|
||||
|
||||
store.dispatch(coreActions.playlistLoaded(playlist));
|
||||
|
||||
Reference in New Issue
Block a user