Upgrading to lookup.uris (no singular uri argument any more); Immutable add_uris prevents track disappearing from lists
This commit is contained in:
@ -70320,7 +70320,7 @@ function clearLibraryArtists() {
|
|||||||
function getArtist(uri) {
|
function getArtist(uri) {
|
||||||
return {
|
return {
|
||||||
type: 'MOPIDY_GET_ARTIST',
|
type: 'MOPIDY_GET_ARTIST',
|
||||||
data: { uri: uri }
|
uri: uri
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71076,12 +71076,12 @@ var MopidyMiddleware = function () {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// split into batches
|
// split into batches
|
||||||
var uris = Object.assign([], action.uris);
|
var _uris = Object.assign([], action.uris);
|
||||||
var batches = [];
|
var batches = [];
|
||||||
var batch_size = 5;
|
var batch_size = 5;
|
||||||
while (uris.length > 0) {
|
while (_uris.length > 0) {
|
||||||
batches.push({
|
batches.push({
|
||||||
uris: uris.splice(0, batch_size),
|
uris: _uris.splice(0, batch_size),
|
||||||
at_position: action.at_position,
|
at_position: action.at_position,
|
||||||
play_next: action.play_next,
|
play_next: action.play_next,
|
||||||
offset: action.offset + batch_size * batches.length,
|
offset: action.offset + batch_size * batches.length,
|
||||||
@ -71183,8 +71183,11 @@ var MopidyMiddleware = function () {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'MOPIDY_PLAY_URIS':
|
case 'MOPIDY_PLAY_URIS':
|
||||||
|
var from_uri = action.from_uri;
|
||||||
|
|
||||||
if (!action.uris || action.uris.length <= 0) {
|
var _uris = Object.assign([], action.uris);
|
||||||
|
|
||||||
|
if (!_uris || !_uris.length) {
|
||||||
_this.props.uiActions.createNotification({ content: 'No URIs to play', type: 'warning' });
|
_this.props.uiActions.createNotification({ content: 'No URIs to play', type: 'warning' });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -71205,7 +71208,7 @@ var MopidyMiddleware = function () {
|
|||||||
} else {
|
} else {
|
||||||
var first_uri_index = 0;
|
var first_uri_index = 0;
|
||||||
}
|
}
|
||||||
var first_uri = action.uris[first_uri_index];
|
var first_uri = _uris[first_uri_index];
|
||||||
|
|
||||||
// add our first track
|
// add our first track
|
||||||
request(socket, store, 'tracklist.add', { uris: [first_uri], at_position: 0 }).then(function (response) {
|
request(socket, store, 'tracklist.add', { uris: [first_uri], at_position: 0 }).then(function (response) {
|
||||||
@ -71217,20 +71220,20 @@ var MopidyMiddleware = function () {
|
|||||||
for (var _i2 = 0; _i2 < response.length; _i2++) {
|
for (var _i2 = 0; _i2 < response.length; _i2++) {
|
||||||
tlids.push(response[_i2].tlid);
|
tlids.push(response[_i2].tlid);
|
||||||
}
|
}
|
||||||
store.dispatch(pusherActions.addQueueMetadata(tlids, action.from_uri));
|
store.dispatch(pusherActions.addQueueMetadata(tlids, from_uri));
|
||||||
} else {
|
} else {
|
||||||
store.dispatch(coreActions.handleException('Mopidy: Failed to add some tracks', response));
|
store.dispatch(coreActions.handleException('Mopidy: Failed to add some tracks', response));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove our first_uri as we've already added it
|
// Remove our first_uri as we've already added it
|
||||||
action.uris.splice(first_uri_index, 1);
|
_uris.splice(first_uri_index, 1);
|
||||||
|
|
||||||
// And add the rest of our uris (if any)
|
// And add the rest of our uris (if any)
|
||||||
if (action.uris.length > 0) {
|
if (_uris.length > 0) {
|
||||||
// Wait a moment so the server can trigger track_changed etc
|
// Wait a moment so the server can trigger track_changed etc
|
||||||
// this means our UI feels snappier as the first track shows up quickly
|
// this means our UI feels snappier as the first track shows up quickly
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
store.dispatch(mopidyActions.enqueueURIs(action.uris, action.from_uri, null, 1));
|
store.dispatch(mopidyActions.enqueueURIs(_uris, from_uri, null, 1));
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
}, function (error) {
|
}, function (error) {
|
||||||
@ -71818,9 +71821,9 @@ var MopidyMiddleware = function () {
|
|||||||
|
|
||||||
case 'MOPIDY_RESOLVE_PLAYLIST_TRACKS':
|
case 'MOPIDY_RESOLVE_PLAYLIST_TRACKS':
|
||||||
var tracks = Object.assign([], action.tracks);
|
var tracks = Object.assign([], action.tracks);
|
||||||
var uris = helpers.arrayOf('uri', tracks);
|
var _uris = helpers.arrayOf('uri', tracks);
|
||||||
|
|
||||||
request(socket, store, 'library.lookup', { uris: uris }).then(function (response) {
|
request(socket, store, 'library.lookup', { uris: _uris }).then(function (response) {
|
||||||
for (var uri in response) {
|
for (var uri in response) {
|
||||||
if (response.hasOwnProperty(uri)) {
|
if (response.hasOwnProperty(uri)) {
|
||||||
var track = response[uri][0];
|
var track = response[uri][0];
|
||||||
@ -72036,15 +72039,15 @@ var MopidyMiddleware = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var uris = Object.assign([], action.data.uris);
|
var _uris = Object.assign([], action.data.uris);
|
||||||
var uris_to_load = uris.splice(0, 50);
|
var uris_to_load = _uris.splice(0, 50);
|
||||||
|
|
||||||
if (uris_to_load.length > 0) {
|
if (uris_to_load.length > 0) {
|
||||||
store.dispatch(uiActions.updateProcess('MOPIDY_LIBRARY_ALBUMS_PROCESSOR', 'Loading ' + uris.length + ' local albums', {
|
store.dispatch(uiActions.updateProcess('MOPIDY_LIBRARY_ALBUMS_PROCESSOR', 'Loading ' + _uris.length + ' local albums', {
|
||||||
uris: uris,
|
uris: _uris,
|
||||||
remaining: uris.length
|
remaining: _uris.length
|
||||||
}));
|
}));
|
||||||
store.dispatch(mopidyActions.getAlbums(uris_to_load, { name: 'MOPIDY_LIBRARY_ALBUMS_PROCESSOR', data: { uris: uris } }));
|
store.dispatch(mopidyActions.getAlbums(uris_to_load, { name: 'MOPIDY_LIBRARY_ALBUMS_PROCESSOR', data: { uris: _uris } }));
|
||||||
} else {
|
} else {
|
||||||
store.dispatch(uiActions.processFinishing('MOPIDY_LIBRARY_ALBUMS_PROCESSOR'));
|
store.dispatch(uiActions.processFinishing('MOPIDY_LIBRARY_ALBUMS_PROCESSOR'));
|
||||||
}
|
}
|
||||||
@ -72286,11 +72289,10 @@ var MopidyMiddleware = function () {
|
|||||||
* */
|
* */
|
||||||
|
|
||||||
case 'MOPIDY_GET_ARTIST':
|
case 'MOPIDY_GET_ARTIST':
|
||||||
request(socket, store, 'library.lookup', action.data).then(function (response) {
|
request(socket, store, 'library.lookup', { uris: [action.uri] }).then(function (response) {
|
||||||
if (response.length <= 0) {
|
console.log(response);
|
||||||
return;
|
if (!response[action.uri] || !response[action.uri].length) return;
|
||||||
}
|
response = response[action.uri];
|
||||||
|
|
||||||
var albums = [];
|
var albums = [];
|
||||||
for (var _i8 = 0; _i8 < response.length; _i8++) {
|
for (var _i8 = 0; _i8 < response.length; _i8++) {
|
||||||
if (response[_i8].album) {
|
if (response[_i8].album) {
|
||||||
@ -72315,7 +72317,7 @@ var MopidyMiddleware = function () {
|
|||||||
|
|
||||||
// Start with an empty artist object
|
// Start with an empty artist object
|
||||||
var artist = {
|
var artist = {
|
||||||
uri: action.data.uri,
|
uri: action.uri,
|
||||||
provider: 'mopidy'
|
provider: 'mopidy'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -100,7 +100,7 @@
|
|||||||
|
|
||||||
// Release details
|
// Release details
|
||||||
// These are automatically injected to built HTML
|
// These are automatically injected to built HTML
|
||||||
var build = "1579256009";
|
var build = "1579284872";
|
||||||
var version = "3.44.0";
|
var version = "3.44.0";
|
||||||
|
|
||||||
// Construct the script tag
|
// Construct the script tag
|
||||||
|
|||||||
@ -429,7 +429,7 @@ export function clearLibraryArtists() {
|
|||||||
export function getArtist(uri) {
|
export function getArtist(uri) {
|
||||||
return {
|
return {
|
||||||
type: 'MOPIDY_GET_ARTIST',
|
type: 'MOPIDY_GET_ARTIST',
|
||||||
data: { uri },
|
uri,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -851,8 +851,10 @@ const MopidyMiddleware = (function () {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'MOPIDY_PLAY_URIS':
|
case 'MOPIDY_PLAY_URIS':
|
||||||
|
const { from_uri } = action;
|
||||||
|
let uris = Object.assign([], action.uris);
|
||||||
|
|
||||||
if (!action.uris || action.uris.length <= 0) {
|
if (!uris || !uris.length) {
|
||||||
this.props.uiActions.createNotification({ content: 'No URIs to play', type: 'warning' });
|
this.props.uiActions.createNotification({ content: 'No URIs to play', type: 'warning' });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -873,7 +875,7 @@ const MopidyMiddleware = (function () {
|
|||||||
} else {
|
} else {
|
||||||
var first_uri_index = 0;
|
var first_uri_index = 0;
|
||||||
}
|
}
|
||||||
var first_uri = action.uris[first_uri_index];
|
var first_uri = uris[first_uri_index];
|
||||||
|
|
||||||
// add our first track
|
// add our first track
|
||||||
request(socket, store, 'tracklist.add', { uris: [first_uri], at_position: 0 })
|
request(socket, store, 'tracklist.add', { uris: [first_uri], at_position: 0 })
|
||||||
@ -887,7 +889,7 @@ const MopidyMiddleware = (function () {
|
|||||||
for (let i = 0; i < response.length; i++) {
|
for (let i = 0; i < response.length; i++) {
|
||||||
tlids.push(response[i].tlid);
|
tlids.push(response[i].tlid);
|
||||||
}
|
}
|
||||||
store.dispatch(pusherActions.addQueueMetadata(tlids, action.from_uri));
|
store.dispatch(pusherActions.addQueueMetadata(tlids, from_uri));
|
||||||
} else {
|
} else {
|
||||||
store.dispatch(coreActions.handleException(
|
store.dispatch(coreActions.handleException(
|
||||||
'Mopidy: Failed to add some tracks',
|
'Mopidy: Failed to add some tracks',
|
||||||
@ -896,15 +898,15 @@ const MopidyMiddleware = (function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove our first_uri as we've already added it
|
// Remove our first_uri as we've already added it
|
||||||
action.uris.splice(first_uri_index, 1);
|
uris.splice(first_uri_index, 1);
|
||||||
|
|
||||||
// And add the rest of our uris (if any)
|
// And add the rest of our uris (if any)
|
||||||
if (action.uris.length > 0) {
|
if (uris.length > 0) {
|
||||||
// Wait a moment so the server can trigger track_changed etc
|
// Wait a moment so the server can trigger track_changed etc
|
||||||
// this means our UI feels snappier as the first track shows up quickly
|
// this means our UI feels snappier as the first track shows up quickly
|
||||||
setTimeout(
|
setTimeout(
|
||||||
() => {
|
() => {
|
||||||
store.dispatch(mopidyActions.enqueueURIs(action.uris, action.from_uri, null, 1));
|
store.dispatch(mopidyActions.enqueueURIs(uris, from_uri, null, 1));
|
||||||
},
|
},
|
||||||
100,
|
100,
|
||||||
);
|
);
|
||||||
@ -2071,17 +2073,15 @@ const MopidyMiddleware = (function () {
|
|||||||
* */
|
* */
|
||||||
|
|
||||||
case 'MOPIDY_GET_ARTIST':
|
case 'MOPIDY_GET_ARTIST':
|
||||||
request(socket, store, 'library.lookup', action.data)
|
request(socket, store, 'library.lookup', { uris: [action.uri] })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.length <= 0) {
|
console.log(response);
|
||||||
return;
|
if (!response[action.uri] || !response[action.uri].length) return;
|
||||||
}
|
response = response[action.uri];
|
||||||
|
|
||||||
const albums = [];
|
const albums = [];
|
||||||
for (let i = 0; i < response.length; i++) {
|
for (let i = 0; i < response.length; i++) {
|
||||||
if (response[i].album) {
|
if (response[i].album) {
|
||||||
var album = {
|
var album = {
|
||||||
|
|
||||||
...response[i].album,
|
...response[i].album,
|
||||||
uri: response[i].album.uri,
|
uri: response[i].album.uri,
|
||||||
};
|
};
|
||||||
@ -2102,7 +2102,7 @@ const MopidyMiddleware = (function () {
|
|||||||
|
|
||||||
// Start with an empty artist object
|
// Start with an empty artist object
|
||||||
let artist = {
|
let artist = {
|
||||||
uri: action.data.uri,
|
uri: action.uri,
|
||||||
provider: 'mopidy',
|
provider: 'mopidy',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user