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