Destructuring of spotify.me.id, should fix #638 (unreproucable)
This commit is contained in:
@ -559,6 +559,13 @@ export function getMore(url, core_action = null, custom_action = null, extra_dat
|
||||
export function getSearchResults({ type, term }, limit = 50, offset = 0) {
|
||||
const processKey = 'SPOTIFY_GET_SEARCH_RESULTS';
|
||||
return (dispatch, getState) => {
|
||||
const {
|
||||
spotify: {
|
||||
me: {
|
||||
id: meId,
|
||||
} = {},
|
||||
},
|
||||
} = getState();
|
||||
dispatch(uiActions.startProcess(processKey, { content: 'Searching Spotify' }));
|
||||
|
||||
let typeString = type.replace(/s+$/, '');
|
||||
@ -602,7 +609,7 @@ export function getSearchResults({ type, term }, limit = 50, offset = 0) {
|
||||
if (response.playlists !== undefined) {
|
||||
const playlists = response.playlists.items.map((item) => ({
|
||||
...formatPlaylist(item),
|
||||
can_edit: (getState().spotify.me && item.owner.id === getState().spotify.me.id),
|
||||
can_edit: (meId === item.owner.id),
|
||||
}));
|
||||
dispatch(coreActions.searchResultsLoaded(
|
||||
{ term, type },
|
||||
@ -747,8 +754,15 @@ export function following(uri, method = 'GET') {
|
||||
}
|
||||
break;
|
||||
case 'playlist':
|
||||
const {
|
||||
spotify: {
|
||||
me: {
|
||||
id: meId,
|
||||
} = {},
|
||||
},
|
||||
} = getState();
|
||||
if (method === 'GET') {
|
||||
endpoint = `playlists/${getFromUri('playlistid', uri)}/followers/contains?ids=${getState().spotify.me.id}`;
|
||||
endpoint = `playlists/${getFromUri('playlistid', uri)}/followers/contains?ids=${meId}`;
|
||||
} else {
|
||||
endpoint = `playlists/${getFromUri('playlistid', uri)}/followers?`;
|
||||
}
|
||||
@ -1221,8 +1235,15 @@ export function createPlaylist(name, description, is_public, is_collaborative) {
|
||||
public: is_public,
|
||||
collaborative: is_collaborative,
|
||||
};
|
||||
const {
|
||||
spotify: {
|
||||
me: {
|
||||
id: meId,
|
||||
} = {},
|
||||
},
|
||||
} = getState();
|
||||
|
||||
request(dispatch, getState, `users/${getState().spotify.me.id}/playlists/`, 'POST', data)
|
||||
request(dispatch, getState, `users/${meId}/playlists/`, 'POST', data)
|
||||
.then(
|
||||
(response) => {
|
||||
dispatch(coreActions.itemLoaded({
|
||||
@ -1256,10 +1277,17 @@ export function savePlaylist(uri, name, description, is_public, is_collaborative
|
||||
public: is_public,
|
||||
collaborative: is_collaborative,
|
||||
};
|
||||
const {
|
||||
spotify: {
|
||||
me: {
|
||||
id: meId,
|
||||
} = {},
|
||||
},
|
||||
} = getState();
|
||||
|
||||
// Update the playlist fields
|
||||
request(
|
||||
dispatch, getState, `users/${getState().spotify.me.id}/playlists/${getFromUri('playlistid', uri)}`, 'PUT', data,
|
||||
dispatch, getState, `users/${meId}/playlists/${getFromUri('playlistid', uri)}`, 'PUT', data,
|
||||
)
|
||||
.then(
|
||||
(response) => {
|
||||
@ -1267,7 +1295,7 @@ export function savePlaylist(uri, name, description, is_public, is_collaborative
|
||||
|
||||
// Save the image
|
||||
if (image) {
|
||||
request(dispatch, getState, `users/${getState().spotify.me.id}/playlists/${getFromUri('playlistid', uri)}/images`, 'PUT', image)
|
||||
request(dispatch, getState, `users/${meId}/playlists/${getFromUri('playlistid', uri)}/images`, 'PUT', image)
|
||||
.then(
|
||||
|
||||
(response) => {
|
||||
@ -1366,6 +1394,13 @@ export function getPlaylist(uri, options) {
|
||||
const { full, forceRefetch } = options;
|
||||
|
||||
return (dispatch, getState) => {
|
||||
const {
|
||||
spotify: {
|
||||
me: {
|
||||
id: meId,
|
||||
} = {},
|
||||
},
|
||||
} = getState();
|
||||
let endpoint = `playlists/${getFromUri('playlistid', uri)}`;
|
||||
endpoint += `?market=${getState().spotify.country}`;
|
||||
if (forceRefetch) endpoint += `&refetch=${Date.now()}`;
|
||||
@ -1389,7 +1424,7 @@ export function getPlaylist(uri, options) {
|
||||
|
||||
dispatch(coreActions.itemLoaded({
|
||||
...formatPlaylist(response),
|
||||
can_edit: (getState().spotify.me && getState().spotify.me.id === response.owner.id),
|
||||
can_edit: (meId === response.owner.id),
|
||||
description,
|
||||
// Remove tracks. They're handed by another query which allows our detector
|
||||
// to accurately identify whether we've loaded *ALL* the tracks. Without this, it
|
||||
@ -1504,6 +1539,13 @@ export function flushLibrary() {
|
||||
|
||||
export function getLibraryPlaylists(forceRefetch) {
|
||||
return (dispatch, getState) => {
|
||||
const {
|
||||
spotify: {
|
||||
me: {
|
||||
id: meId,
|
||||
} = {},
|
||||
},
|
||||
} = getState();
|
||||
const processKey = 'SPOTIFY_GET_LIBRARY_PLAYLISTS';
|
||||
dispatch(uiActions.startProcess(processKey, { notification: false }));
|
||||
|
||||
@ -1526,7 +1568,7 @@ export function getLibraryPlaylists(forceRefetch) {
|
||||
(item) => ({
|
||||
...formatPlaylist(item),
|
||||
in_library: true,
|
||||
can_edit: (getState().spotify.me && item.owner.id === getState().spotify.me.id),
|
||||
can_edit: (meId === item.owner.id),
|
||||
}),
|
||||
);
|
||||
libraryItems = [...libraryItems, ...items];
|
||||
|
||||
@ -61,7 +61,7 @@ class QueueHistory extends React.Component {
|
||||
<Icon name="play_arrow" type="material" />
|
||||
</I18n>
|
||||
</Header>
|
||||
{tracks && (
|
||||
{tracks.length > 0 && (
|
||||
<section className="content-wrapper">
|
||||
<TrackList
|
||||
uri="iris:queue-history"
|
||||
|
||||
@ -354,6 +354,13 @@ class LibraryPlaylists extends React.Component {
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const source = state.ui.library_playlists_source || 'all';
|
||||
const {
|
||||
spotify: {
|
||||
me: {
|
||||
id: me_id,
|
||||
} = {},
|
||||
},
|
||||
} = state;
|
||||
|
||||
const libraryUris = [];
|
||||
if (source === 'all' || source === 'local') libraryUris.push('mopidy:library:playlists');
|
||||
@ -369,7 +376,7 @@ const mapStateToProps = (state) => {
|
||||
playlists: librarySelector(state),
|
||||
loading_progress: processProgressSelector(state),
|
||||
source,
|
||||
me_id: (state.spotify.me ? state.spotify.me.id : false),
|
||||
me_id,
|
||||
view: state.ui.library_playlists_view,
|
||||
sort: (state.ui.library_playlists_sort ? state.ui.library_playlists_sort : null),
|
||||
sort_reverse: (state.ui.library_playlists_sort_reverse ? state.ui.library_playlists_sort_reverse : false),
|
||||
|
||||
@ -106,17 +106,39 @@ class AddToPlaylist extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
uris: (ownProps.match.params.uris ? decodeURIComponent(ownProps.match.params.uris).split(',') : []),
|
||||
mopidy_uri_schemes: state.mopidy.uri_schemes,
|
||||
items: state.core.items,
|
||||
mopidy_library: state.core.libraries['mopidy:library:playlists'],
|
||||
spotify_library: state.core.libraries['spotify:library:playlists'],
|
||||
spotify_available: state.spotify.access_token,
|
||||
load_queue: state.ui.load_queue,
|
||||
me_id: (state.spotify.me ? state.spotify.me.id : false),
|
||||
playlists: state.core.playlists,
|
||||
});
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const {
|
||||
spotify: {
|
||||
me: {
|
||||
id: me_id,
|
||||
} = {},
|
||||
access_token: spotify_available,
|
||||
},
|
||||
ui: {
|
||||
load_queue,
|
||||
},
|
||||
core: {
|
||||
playlists,
|
||||
items,
|
||||
libraries,
|
||||
},
|
||||
mopidy: {
|
||||
uri_schemes: mopidy_uri_schemes,
|
||||
}
|
||||
} = state;
|
||||
|
||||
return {
|
||||
uris: (ownProps.match.params.uris ? decodeURIComponent(ownProps.match.params.uris).split(',') : []),
|
||||
mopidy_uri_schemes,
|
||||
items,
|
||||
mopidy_library: libraries['mopidy:library:playlists'],
|
||||
spotify_library: libraries['spotify:library:playlists'],
|
||||
spotify_available,
|
||||
load_queue,
|
||||
me_id,
|
||||
playlists,
|
||||
};
|
||||
};
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
coreActions: bindActionCreators(coreActions, dispatch),
|
||||
|
||||
@ -297,7 +297,7 @@ class ShareConfiguration extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
const mapStateToProps = (state) => ({
|
||||
spotify_authorization: state.spotify.authorization,
|
||||
spotify_me: state.spotify.me,
|
||||
genius_authorization: state.genius.authorization,
|
||||
|
||||
Reference in New Issue
Block a user