decodeURIComponent for local directories, fixes #639; Use socket to check for mopidy connection;
This commit is contained in:
@ -121353,7 +121353,7 @@ var MopidyMiddleware = function () {
|
||||
}; // Give a 5-second leeway for allowing Mopidy to connect, if it isn't already connected
|
||||
|
||||
|
||||
if (store.getState().mopidy.connected) {
|
||||
if (socket) {
|
||||
doRequest();
|
||||
} else {
|
||||
console.info('Mopidy not yet connected, waiting 2 seconds');
|
||||
@ -122621,21 +122621,22 @@ var MopidyMiddleware = function () {
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_DIRECTORY_FLUSH'
|
||||
});
|
||||
var uri = action.uri ? decodeURIComponent(action.uri) : null;
|
||||
|
||||
if (action.uri) {
|
||||
if (uri) {
|
||||
request(store, 'library.lookup', {
|
||||
uris: [action.uri]
|
||||
uris: [uri]
|
||||
}).then(function (response) {
|
||||
if (!response[action.uri] || !response[action.uri].length) return;
|
||||
if (!response[uri] || !response[uri].length) return;
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_DIRECTORY_LOADED',
|
||||
directory: Object(_util_format__WEBPACK_IMPORTED_MODULE_6__["formatSimpleObject"])(response[action.uri][0])
|
||||
directory: Object(_util_format__WEBPACK_IMPORTED_MODULE_6__["formatSimpleObject"])(response[uri][0])
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
request(store, 'library.browse', {
|
||||
uri: action.uri
|
||||
uri: uri
|
||||
}).then(function (response) {
|
||||
var tracks_uris = [];
|
||||
var tracks = [];
|
||||
@ -122692,9 +122693,9 @@ var MopidyMiddleware = function () {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var uri in response) {
|
||||
if (response.hasOwnProperty(uri) && response[uri].length > 0) {
|
||||
tracks.push(Object(_util_format__WEBPACK_IMPORTED_MODULE_6__["formatTrack"])(response[uri][0]));
|
||||
for (var _uri in response) {
|
||||
if (response.hasOwnProperty(_uri) && response[_uri].length > 0) {
|
||||
tracks.push(Object(_util_format__WEBPACK_IMPORTED_MODULE_6__["formatTrack"])(response[_uri][0]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -125878,6 +125879,11 @@ function getSearchResults(_ref3) {
|
||||
var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
||||
var processKey = 'SPOTIFY_GET_SEARCH_RESULTS';
|
||||
return function (dispatch, getState) {
|
||||
var _getState = getState(),
|
||||
_getState$spotify$me = _getState.spotify.me;
|
||||
|
||||
_getState$spotify$me = _getState$spotify$me === void 0 ? {} : _getState$spotify$me;
|
||||
var meId = _getState$spotify$me.id;
|
||||
dispatch(uiActions.startProcess(processKey, {
|
||||
content: 'Searching Spotify'
|
||||
}));
|
||||
@ -125917,7 +125923,7 @@ function getSearchResults(_ref3) {
|
||||
if (response.playlists !== undefined) {
|
||||
var playlists = response.playlists.items.map(function (item) {
|
||||
return _objectSpread(_objectSpread({}, Object(_util_format__WEBPACK_IMPORTED_MODULE_3__["formatPlaylist"])(item)), {}, {
|
||||
can_edit: getState().spotify.me && item.owner.id === getState().spotify.me.id
|
||||
can_edit: meId === item.owner.id
|
||||
});
|
||||
});
|
||||
dispatch(coreActions.searchResultsLoaded({
|
||||
@ -126062,8 +126068,14 @@ function following(uri) {
|
||||
break;
|
||||
|
||||
case 'playlist':
|
||||
var _getState2 = getState(),
|
||||
_getState2$spotify$me = _getState2.spotify.me;
|
||||
|
||||
_getState2$spotify$me = _getState2$spotify$me === void 0 ? {} : _getState2$spotify$me;
|
||||
var meId = _getState2$spotify$me.id;
|
||||
|
||||
if (method === 'GET') {
|
||||
endpoint = "playlists/".concat(Object(_util_helpers__WEBPACK_IMPORTED_MODULE_2__["getFromUri"])('playlistid', uri), "/followers/contains?ids=").concat(getState().spotify.me.id);
|
||||
endpoint = "playlists/".concat(Object(_util_helpers__WEBPACK_IMPORTED_MODULE_2__["getFromUri"])('playlistid', uri), "/followers/contains?ids=").concat(meId);
|
||||
} else {
|
||||
endpoint = "playlists/".concat(Object(_util_helpers__WEBPACK_IMPORTED_MODULE_2__["getFromUri"])('playlistid', uri), "/followers?");
|
||||
}
|
||||
@ -126488,7 +126500,13 @@ function createPlaylist(name, description, is_public, is_collaborative) {
|
||||
"public": is_public,
|
||||
collaborative: is_collaborative
|
||||
};
|
||||
request(dispatch, getState, "users/".concat(getState().spotify.me.id, "/playlists/"), 'POST', data).then(function (response) {
|
||||
|
||||
var _getState3 = getState(),
|
||||
_getState3$spotify$me = _getState3.spotify.me;
|
||||
|
||||
_getState3$spotify$me = _getState3$spotify$me === void 0 ? {} : _getState3$spotify$me;
|
||||
var meId = _getState3$spotify$me.id;
|
||||
request(dispatch, getState, "users/".concat(meId, "/playlists/"), 'POST', data).then(function (response) {
|
||||
dispatch(coreActions.itemLoaded(_objectSpread(_objectSpread({}, Object(_util_format__WEBPACK_IMPORTED_MODULE_3__["formatPlaylist"])(response)), {}, {
|
||||
can_edit: true,
|
||||
tracks: []
|
||||
@ -126512,16 +126530,22 @@ function savePlaylist(uri, name, description, is_public, is_collaborative, image
|
||||
description: description,
|
||||
"public": is_public,
|
||||
collaborative: is_collaborative
|
||||
}; // Update the playlist fields
|
||||
};
|
||||
|
||||
request(dispatch, getState, "users/".concat(getState().spotify.me.id, "/playlists/").concat(Object(_util_helpers__WEBPACK_IMPORTED_MODULE_2__["getFromUri"])('playlistid', uri)), 'PUT', data).then(function (response) {
|
||||
var _getState4 = getState(),
|
||||
_getState4$spotify$me = _getState4.spotify.me;
|
||||
|
||||
_getState4$spotify$me = _getState4$spotify$me === void 0 ? {} : _getState4$spotify$me;
|
||||
var meId = _getState4$spotify$me.id; // Update the playlist fields
|
||||
|
||||
request(dispatch, getState, "users/".concat(meId, "/playlists/").concat(Object(_util_helpers__WEBPACK_IMPORTED_MODULE_2__["getFromUri"])('playlistid', uri)), 'PUT', data).then(function (response) {
|
||||
dispatch(uiActions.createNotification({
|
||||
level: 'warning',
|
||||
content: 'Playlist saved'
|
||||
})); // Save the image
|
||||
|
||||
if (image) {
|
||||
request(dispatch, getState, "users/".concat(getState().spotify.me.id, "/playlists/").concat(Object(_util_helpers__WEBPACK_IMPORTED_MODULE_2__["getFromUri"])('playlistid', uri), "/images"), 'PUT', image).then(function (response) {
|
||||
request(dispatch, getState, "users/".concat(meId, "/playlists/").concat(Object(_util_helpers__WEBPACK_IMPORTED_MODULE_2__["getFromUri"])('playlistid', uri), "/images"), 'PUT', image).then(function (response) {
|
||||
dispatch({
|
||||
type: 'PLAYLIST_UPDATED',
|
||||
key: uri,
|
||||
@ -126601,6 +126625,11 @@ function getPlaylist(uri, options) {
|
||||
var full = options.full,
|
||||
forceRefetch = options.forceRefetch;
|
||||
return function (dispatch, getState) {
|
||||
var _getState5 = getState(),
|
||||
_getState5$spotify$me = _getState5.spotify.me;
|
||||
|
||||
_getState5$spotify$me = _getState5$spotify$me === void 0 ? {} : _getState5$spotify$me;
|
||||
var meId = _getState5$spotify$me.id;
|
||||
var endpoint = "playlists/".concat(Object(_util_helpers__WEBPACK_IMPORTED_MODULE_2__["getFromUri"])('playlistid', uri));
|
||||
endpoint += "?market=".concat(getState().spotify.country);
|
||||
if (forceRefetch) endpoint += "&refetch=".concat(Date.now()); // TODO
|
||||
@ -126620,7 +126649,7 @@ function getPlaylist(uri, options) {
|
||||
}
|
||||
|
||||
dispatch(coreActions.itemLoaded(_objectSpread(_objectSpread({}, Object(_util_format__WEBPACK_IMPORTED_MODULE_3__["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
|
||||
// to accurately identify whether we've loaded *ALL* the tracks. Without this, it
|
||||
@ -126705,6 +126734,11 @@ function flushLibrary() {
|
||||
}
|
||||
function getLibraryPlaylists(forceRefetch) {
|
||||
return function (dispatch, getState) {
|
||||
var _getState6 = getState(),
|
||||
_getState6$spotify$me = _getState6.spotify.me;
|
||||
|
||||
_getState6$spotify$me = _getState6$spotify$me === void 0 ? {} : _getState6$spotify$me;
|
||||
var meId = _getState6$spotify$me.id;
|
||||
var processKey = 'SPOTIFY_GET_LIBRARY_PLAYLISTS';
|
||||
dispatch(uiActions.startProcess(processKey, {
|
||||
notification: false
|
||||
@ -126728,7 +126762,7 @@ function getLibraryPlaylists(forceRefetch) {
|
||||
var items = response.items.map(function (item) {
|
||||
return _objectSpread(_objectSpread({}, Object(_util_format__WEBPACK_IMPORTED_MODULE_3__["formatPlaylist"])(item)), {}, {
|
||||
in_library: true,
|
||||
can_edit: getState().spotify.me && item.owner.id === getState().spotify.me.id
|
||||
can_edit: meId === item.owner.id
|
||||
});
|
||||
});
|
||||
libraryItems = [].concat(_toConsumableArray(libraryItems), _toConsumableArray(items));
|
||||
@ -137126,7 +137160,7 @@ var QueueHistory = /*#__PURE__*/function (_React$Component) {
|
||||
type: "material",
|
||||
"data-qa-node": "Icon",
|
||||
"data-qa-file": "QueueHistory"
|
||||
}))), tracks && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("section", {
|
||||
}))), tracks.length > 0 && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("section", {
|
||||
className: "content-wrapper",
|
||||
"data-qa-node": "section",
|
||||
"data-qa-file": "QueueHistory"
|
||||
@ -143556,6 +143590,9 @@ var LibraryPlaylists = /*#__PURE__*/function (_React$Component) {
|
||||
|
||||
var mapStateToProps = function mapStateToProps(state) {
|
||||
var source = state.ui.library_playlists_source || 'all';
|
||||
var _state$spotify$me = state.spotify.me;
|
||||
_state$spotify$me = _state$spotify$me === void 0 ? {} : _state$spotify$me;
|
||||
var me_id = _state$spotify$me.id;
|
||||
var libraryUris = [];
|
||||
if (source === 'all' || source === 'local') libraryUris.push('mopidy:library:playlists');
|
||||
if (source === 'all' || source === 'spotify') libraryUris.push('spotify:library:playlists');
|
||||
@ -143569,7 +143606,7 @@ var mapStateToProps = function mapStateToProps(state) {
|
||||
playlists: librarySelector(state),
|
||||
loading_progress: processProgressSelector(state),
|
||||
source: source,
|
||||
me_id: state.spotify.me ? state.spotify.me.id : false,
|
||||
me_id: 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
|
||||
@ -144230,16 +144267,27 @@ var AddToPlaylist = /*#__PURE__*/function (_React$Component) {
|
||||
}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);
|
||||
|
||||
var mapStateToProps = function mapStateToProps(state, ownProps) {
|
||||
var _state$spotify = state.spotify,
|
||||
_state$spotify$me = _state$spotify.me;
|
||||
_state$spotify$me = _state$spotify$me === void 0 ? {} : _state$spotify$me;
|
||||
var me_id = _state$spotify$me.id,
|
||||
spotify_available = _state$spotify.access_token,
|
||||
load_queue = state.ui.load_queue,
|
||||
_state$core = state.core,
|
||||
playlists = _state$core.playlists,
|
||||
items = _state$core.items,
|
||||
libraries = _state$core.libraries,
|
||||
mopidy_uri_schemes = state.mopidy.uri_schemes;
|
||||
return {
|
||||
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
|
||||
mopidy_uri_schemes: mopidy_uri_schemes,
|
||||
items: items,
|
||||
mopidy_library: libraries['mopidy:library:playlists'],
|
||||
spotify_library: libraries['spotify:library:playlists'],
|
||||
spotify_available: spotify_available,
|
||||
load_queue: load_queue,
|
||||
me_id: me_id,
|
||||
playlists: playlists
|
||||
};
|
||||
};
|
||||
|
||||
@ -147985,7 +148033,7 @@ var ShareConfiguration = /*#__PURE__*/function (_React$Component) {
|
||||
return ShareConfiguration;
|
||||
}(react__WEBPACK_IMPORTED_MODULE_0___default.a.Component);
|
||||
|
||||
var mapStateToProps = function mapStateToProps(state, ownProps) {
|
||||
var mapStateToProps = function mapStateToProps(state) {
|
||||
return {
|
||||
spotify_authorization: state.spotify.authorization,
|
||||
spotify_me: state.spotify.me,
|
||||
|
||||
File diff suppressed because one or more lines are too long
14
mopidy_iris/static/app.min.js
vendored
14
mopidy_iris/static/app.min.js
vendored
File diff suppressed because one or more lines are too long
@ -106,7 +106,7 @@
|
||||
|
||||
// Release details
|
||||
// These are automatically injected to built HTML
|
||||
var build = "1605078452";
|
||||
var build = "1605082418";
|
||||
var version = "3.54.0";
|
||||
|
||||
// Construct the script tag
|
||||
|
||||
@ -228,7 +228,7 @@ const MopidyMiddleware = (function () {
|
||||
};
|
||||
|
||||
// Give a 5-second leeway for allowing Mopidy to connect, if it isn't already connected
|
||||
if (store.getState().mopidy.connected) {
|
||||
if (socket) {
|
||||
doRequest();
|
||||
} else {
|
||||
console.info('Mopidy not yet connected, waiting 2 seconds');
|
||||
@ -1606,19 +1606,20 @@ const MopidyMiddleware = (function () {
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_DIRECTORY_FLUSH',
|
||||
});
|
||||
const uri = action.uri ? decodeURIComponent(action.uri) : null;
|
||||
|
||||
if (action.uri) {
|
||||
request(store, 'library.lookup', { uris: [action.uri] })
|
||||
if (uri) {
|
||||
request(store, 'library.lookup', { uris: [uri] })
|
||||
.then((response) => {
|
||||
if (!response[action.uri] || !response[action.uri].length) return;
|
||||
if (!response[uri] || !response[uri].length) return;
|
||||
store.dispatch({
|
||||
type: 'MOPIDY_DIRECTORY_LOADED',
|
||||
directory: formatSimpleObject(response[action.uri][0]),
|
||||
directory: formatSimpleObject(response[uri][0]),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
request(store, 'library.browse', { uri: action.uri })
|
||||
request(store, 'library.browse', { uri })
|
||||
.then((response) => {
|
||||
const tracks_uris = [];
|
||||
const tracks = [];
|
||||
@ -1643,8 +1644,8 @@ const MopidyMiddleware = (function () {
|
||||
}
|
||||
return {
|
||||
...subdir,
|
||||
images: images,
|
||||
}
|
||||
images,
|
||||
};
|
||||
});
|
||||
|
||||
store.dispatch({
|
||||
|
||||
Reference in New Issue
Block a user