Updating pinned URIs when they change (eg renaming local playlist)
This commit is contained in:
@ -99260,7 +99260,7 @@ module.exports = JSON.parse("{\"name\":\"Svenska\",\"errors\":{\"uri_not_found\"
|
|||||||
/*!*****************************************!*\
|
/*!*****************************************!*\
|
||||||
!*** ./src/js/services/core/actions.js ***!
|
!*** ./src/js/services/core/actions.js ***!
|
||||||
\*****************************************/
|
\*****************************************/
|
||||||
/*! exports provided: getBroadcasts, startSearch, handleException, debugResponse, set, clearCurrentTrack, cachebustHttpStream, loadItems, loadItem, loadTrack, loadAlbum, loadArtist, loadPlaylist, loadUser, loadUserPlaylists, trackLoaded, tracksLoaded, artistLoaded, artistsLoaded, albumLoaded, albumsLoaded, playlistLoaded, playlistsLoaded, userLoaded, usersLoaded, userPlaylistsLoaded, loadedMore, removeFromIndex, viewDataLoaded, reorderPlaylistTracks, savePlaylist, createPlaylist, deletePlaylist, removeTracksFromPlaylist, addTracksToPlaylist, getLibraryPlaylists, getLibraryAlbums, getLibraryArtists, addPinned, removePinned, updatePinned */
|
/*! exports provided: getBroadcasts, startSearch, handleException, debugResponse, set, clearCurrentTrack, cachebustHttpStream, loadItems, loadItem, loadTrack, loadAlbum, loadArtist, loadPlaylist, loadUser, loadUserPlaylists, trackLoaded, tracksLoaded, artistLoaded, artistsLoaded, albumLoaded, albumsLoaded, playlistLoaded, playlistsLoaded, userLoaded, usersLoaded, userPlaylistsLoaded, loadedMore, removeFromIndex, viewDataLoaded, reorderPlaylistTracks, savePlaylist, createPlaylist, deletePlaylist, removeTracksFromPlaylist, addTracksToPlaylist, getLibraryPlaylists, getLibraryAlbums, getLibraryArtists, addPinned, removePinned, updatePinned, updatePinnedUri */
|
||||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
@ -99306,6 +99306,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addPinned", function() { return addPinned; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addPinned", function() { return addPinned; });
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removePinned", function() { return removePinned; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removePinned", function() { return removePinned; });
|
||||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updatePinned", function() { return updatePinned; });
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updatePinned", function() { return updatePinned; });
|
||||||
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updatePinnedUri", function() { return updatePinnedUri; });
|
||||||
/* harmony import */ var _util_arrays__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../util/arrays */ "./src/js/util/arrays.js");
|
/* harmony import */ var _util_arrays__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../util/arrays */ "./src/js/util/arrays.js");
|
||||||
/* harmony import */ var _util_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../util/helpers */ "./src/js/util/helpers.js");
|
/* harmony import */ var _util_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../util/helpers */ "./src/js/util/helpers.js");
|
||||||
|
|
||||||
@ -99741,6 +99742,13 @@ function updatePinned(pinned) {
|
|||||||
pinned: Object(_util_arrays__WEBPACK_IMPORTED_MODULE_0__["removeDuplicates"])(pinned)
|
pinned: Object(_util_arrays__WEBPACK_IMPORTED_MODULE_0__["removeDuplicates"])(pinned)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
function updatePinnedUri(oldUri, newUri) {
|
||||||
|
return {
|
||||||
|
type: 'UPDATE_PINNED_URI',
|
||||||
|
oldUri: oldUri,
|
||||||
|
newUri: newUri
|
||||||
|
};
|
||||||
|
}
|
||||||
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js")))
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js")))
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@ -100706,6 +100714,18 @@ var CoreMiddleware = function () {
|
|||||||
})));
|
})));
|
||||||
next(action);
|
next(action);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'UPDATE_PINNED_URI':
|
||||||
|
var pinnedUris = store.getState().core.pinned;
|
||||||
|
var pinnedUriIndex = pinnedUris.indexOf(action.oldUri);
|
||||||
|
|
||||||
|
if (pinnedUriIndex > -1) {
|
||||||
|
pinnedUris[pinnedUriIndex] = action.newUri;
|
||||||
|
store.dispatch(coreActions.updatePinned(pinnedUris));
|
||||||
|
}
|
||||||
|
|
||||||
|
next(action);
|
||||||
|
break;
|
||||||
// This action is irrelevant to us, pass it on to the next middleware
|
// This action is irrelevant to us, pass it on to the next middleware
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -103544,11 +103564,7 @@ var MopidyMiddleware = function () {
|
|||||||
if (controller) {
|
if (controller) {
|
||||||
var timeout = setTimeout(function () {
|
var timeout = setTimeout(function () {
|
||||||
store.dispatch(uiActions.stopLoading(loader_key));
|
store.dispatch(uiActions.stopLoading(loader_key));
|
||||||
reject({
|
reject(new Error('Request timed out'));
|
||||||
message: 'Request timed out',
|
|
||||||
call: call,
|
|
||||||
value: value
|
|
||||||
});
|
|
||||||
}, 30000);
|
}, 30000);
|
||||||
controller(value).then(function (response) {
|
controller(value).then(function (response) {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
@ -103562,7 +103578,7 @@ var MopidyMiddleware = function () {
|
|||||||
} else {
|
} else {
|
||||||
// Controller (model.method) doesn't exist, or connection not established
|
// Controller (model.method) doesn't exist, or connection not established
|
||||||
store.dispatch(uiActions.stopLoading(loader_key));
|
store.dispatch(uiActions.stopLoading(loader_key));
|
||||||
console.warn('Mopidy request aborted. This could be due to an invalid request, or Mopidy is not connected. Check the request and your server settings.', {
|
console.warn('Mopidy request aborted. Either Mopidy is not connected or the request method is invalid. Check the request and your server settings.', {
|
||||||
call: call,
|
call: call,
|
||||||
value: value
|
value: value
|
||||||
});
|
});
|
||||||
@ -104822,6 +104838,8 @@ var MopidyMiddleware = function () {
|
|||||||
|
|
||||||
case 'MOPIDY_GET_PLAYLIST':
|
case 'MOPIDY_GET_PLAYLIST':
|
||||||
request(store, 'playlists.lookup', action.data).then(function (response) {
|
request(store, 'playlists.lookup', action.data).then(function (response) {
|
||||||
|
if (!response) return;
|
||||||
|
|
||||||
var playlist = _objectSpread(_objectSpread({}, response), {}, {
|
var playlist = _objectSpread(_objectSpread({}, response), {}, {
|
||||||
uri: response.uri,
|
uri: response.uri,
|
||||||
type: 'playlist',
|
type: 'playlist',
|
||||||
@ -104953,8 +104971,9 @@ var MopidyMiddleware = function () {
|
|||||||
request(store, 'playlists.save', {
|
request(store, 'playlists.save', {
|
||||||
playlist: mopidy_playlist
|
playlist: mopidy_playlist
|
||||||
}).then(function (response) {
|
}).then(function (response) {
|
||||||
// Overwrite our playlist with the response to our save
|
if (!response) return; // Overwrite our playlist with the response to our save
|
||||||
// This is essential to get the updated URI from Mopidy
|
// This is essential to get the updated URI from Mopidy
|
||||||
|
|
||||||
var playlist = _objectSpread(_objectSpread({}, store.getState().core.playlists[action.key]), {}, {
|
var playlist = _objectSpread(_objectSpread({}, store.getState().core.playlists[action.key]), {}, {
|
||||||
uri: response.uri,
|
uri: response.uri,
|
||||||
name: response.name
|
name: response.name
|
||||||
@ -104966,11 +104985,11 @@ var MopidyMiddleware = function () {
|
|||||||
// Remove old playlist (by old key/uri) from index
|
// Remove old playlist (by old key/uri) from index
|
||||||
// By providing the new key, the old playlist gets replaced with a redirector object
|
// 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.removeFromIndex('playlists', action.key, playlist.uri));
|
||||||
|
store.dispatch(coreActions.updatePinnedUri(action.key, playlist.uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
store.dispatch(coreActions.playlistLoaded(playlist));
|
store.dispatch(coreActions.playlistLoaded(playlist));
|
||||||
store.dispatch(uiActions.createNotification({
|
store.dispatch(uiActions.createNotification({
|
||||||
level: 'warning',
|
|
||||||
content: 'Playlist saved'
|
content: 'Playlist saved'
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -106,7 +106,7 @@
|
|||||||
|
|
||||||
// Release details
|
// Release details
|
||||||
// These are automatically injected to built HTML
|
// These are automatically injected to built HTML
|
||||||
var build = "1597176642";
|
var build = "1597216412";
|
||||||
var version = "3.51.0";
|
var version = "3.51.0";
|
||||||
|
|
||||||
// Construct the script tag
|
// Construct the script tag
|
||||||
|
|||||||
@ -449,3 +449,11 @@ export function updatePinned(pinned) {
|
|||||||
pinned: removeDuplicates(pinned),
|
pinned: removeDuplicates(pinned),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function updatePinnedUri(oldUri, newUri) {
|
||||||
|
return {
|
||||||
|
type: 'UPDATE_PINNED_URI',
|
||||||
|
oldUri,
|
||||||
|
newUri,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@ -803,6 +803,16 @@ const CoreMiddleware = (function () {
|
|||||||
next(action);
|
next(action);
|
||||||
break;
|
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));
|
||||||
|
}
|
||||||
|
next(action);
|
||||||
|
break;
|
||||||
|
|
||||||
// This action is irrelevant to us, pass it on to the next middleware
|
// This action is irrelevant to us, pass it on to the next middleware
|
||||||
default:
|
default:
|
||||||
return next(action);
|
return next(action);
|
||||||
|
|||||||
@ -191,11 +191,7 @@ const MopidyMiddleware = (function () {
|
|||||||
const timeout = setTimeout(
|
const timeout = setTimeout(
|
||||||
() => {
|
() => {
|
||||||
store.dispatch(uiActions.stopLoading(loader_key));
|
store.dispatch(uiActions.stopLoading(loader_key));
|
||||||
reject({
|
reject(new Error('Request timed out'));
|
||||||
message: 'Request timed out',
|
|
||||||
call,
|
|
||||||
value,
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
30000,
|
30000,
|
||||||
);
|
);
|
||||||
@ -217,7 +213,7 @@ const MopidyMiddleware = (function () {
|
|||||||
// Controller (model.method) doesn't exist, or connection not established
|
// Controller (model.method) doesn't exist, or connection not established
|
||||||
store.dispatch(uiActions.stopLoading(loader_key));
|
store.dispatch(uiActions.stopLoading(loader_key));
|
||||||
console.warn(
|
console.warn(
|
||||||
'Mopidy request aborted. This could be due to an invalid request, or Mopidy is not connected. Check the request and your server settings.',
|
'Mopidy request aborted. Either Mopidy is not connected or the request method is invalid. Check the request and your server settings.',
|
||||||
{ call, value },
|
{ call, value },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1643,6 +1639,8 @@ const MopidyMiddleware = (function () {
|
|||||||
case 'MOPIDY_GET_PLAYLIST':
|
case 'MOPIDY_GET_PLAYLIST':
|
||||||
request(store, 'playlists.lookup', action.data)
|
request(store, 'playlists.lookup', action.data)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
if (!response) return;
|
||||||
|
|
||||||
const playlist = {
|
const playlist = {
|
||||||
...response,
|
...response,
|
||||||
uri: response.uri,
|
uri: response.uri,
|
||||||
@ -1765,10 +1763,11 @@ const MopidyMiddleware = (function () {
|
|||||||
|
|
||||||
request(store, 'playlists.save', { playlist: mopidy_playlist })
|
request(store, 'playlists.save', { playlist: mopidy_playlist })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
if (!response) return;
|
||||||
|
|
||||||
// Overwrite our playlist with the response to our save
|
// Overwrite our playlist with the response to our save
|
||||||
// This is essential to get the updated URI from Mopidy
|
// This is essential to get the updated URI from Mopidy
|
||||||
const playlist = {
|
const playlist = {
|
||||||
|
|
||||||
...store.getState().core.playlists[action.key],
|
...store.getState().core.playlists[action.key],
|
||||||
uri: response.uri,
|
uri: response.uri,
|
||||||
name: response.name,
|
name: response.name,
|
||||||
@ -1780,11 +1779,11 @@ const MopidyMiddleware = (function () {
|
|||||||
// Remove old playlist (by old key/uri) from index
|
// Remove old playlist (by old key/uri) from index
|
||||||
// By providing the new key, the old playlist gets replaced with a redirector object
|
// 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.removeFromIndex('playlists', action.key, playlist.uri));
|
||||||
|
store.dispatch(coreActions.updatePinnedUri(action.key, playlist.uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
store.dispatch(coreActions.playlistLoaded(playlist));
|
store.dispatch(coreActions.playlistLoaded(playlist));
|
||||||
|
store.dispatch(uiActions.createNotification({ content: 'Playlist saved' }));
|
||||||
store.dispatch(uiActions.createNotification({ level: 'warning', content: 'Playlist saved' }));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user