Everything goes through loadItem; Options now provide 'full' switch for full asset on demand
This commit is contained in:
@ -90022,7 +90022,9 @@ var ContextMenu = /*#__PURE__*/function (_React$Component) {
|
||||
_this$props28$menu = _this$props28$menu === void 0 ? {} : _this$props28$menu;
|
||||
var uris = _this$props28$menu.uris;
|
||||
var uri = uris[0];
|
||||
loadItem(uri, true);
|
||||
loadItem(uri, {
|
||||
forceRefetch: true
|
||||
});
|
||||
hideContextMenu();
|
||||
});
|
||||
|
||||
@ -91035,23 +91037,23 @@ var mapStateToProps = function mapStateToProps(state) {
|
||||
current_tracklist: state.core.current_tracklist,
|
||||
queue_metadata: state.core.queue_metadata,
|
||||
spotify_available: state.spotify.access_token,
|
||||
spotify_library_playlists: state.core.items['spotify:library:playlists'] || {
|
||||
spotify_library_playlists: state.core.libraries['spotify:library:playlists'] || {
|
||||
items_uris: []
|
||||
},
|
||||
spotify_library_artists: state.core.items['spotify:library:artists'] || {
|
||||
spotify_library_artists: state.core.libraries['spotify:library:artists'] || {
|
||||
items_uris: []
|
||||
},
|
||||
spotify_library_albums: state.core.items['spotify:library:albums'] || {
|
||||
spotify_library_albums: state.core.libraries['spotify:library:albums'] || {
|
||||
items_uris: []
|
||||
},
|
||||
spotify_library_tracks: state.spotify.library_tracks,
|
||||
mopidy_library_playlists: state.core.items['mopidy:library:playlists'] || {
|
||||
mopidy_library_playlists: state.core.libraries['mopidy:library:playlists'] || {
|
||||
items_uris: []
|
||||
},
|
||||
mopidy_library_artists: state.core.items['mopidy:library:artists'] || {
|
||||
mopidy_library_artists: state.core.libraries['mopidy:library:artists'] || {
|
||||
items_uris: []
|
||||
},
|
||||
mopidy_library_albums: state.core.items['mopidy:library:albums'] || {
|
||||
mopidy_library_albums: state.core.libraries['mopidy:library:albums'] || {
|
||||
items_uris: []
|
||||
},
|
||||
playlists: state.core.playlists,
|
||||
@ -103789,80 +103791,70 @@ function updateColdStore(items) {
|
||||
* */
|
||||
|
||||
function loadItems(uris) {
|
||||
var forceRefetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
var callbackAction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
return {
|
||||
type: 'LOAD_ITEMS',
|
||||
uris: uris,
|
||||
forceRefetch: forceRefetch,
|
||||
callbackAction: callbackAction
|
||||
options: options
|
||||
};
|
||||
}
|
||||
function loadItem(uri) {
|
||||
var forceRefetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
var callbackAction = arguments.length > 2 ? arguments[2] : undefined;
|
||||
return loadItems([uri], forceRefetch, callbackAction);
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
return loadItems([uri], options);
|
||||
}
|
||||
function loadTrack(uri) {
|
||||
var forceRefetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
return {
|
||||
type: 'LOAD_TRACK',
|
||||
uri: uri,
|
||||
forceRefetch: forceRefetch
|
||||
options: options
|
||||
};
|
||||
}
|
||||
function loadAlbum(uri) {
|
||||
var forceRefetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
var callbackAction = arguments.length > 2 ? arguments[2] : undefined;
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
return {
|
||||
type: 'LOAD_ALBUM',
|
||||
uri: uri,
|
||||
forceRefetch: forceRefetch,
|
||||
callbackAction: callbackAction
|
||||
options: options
|
||||
};
|
||||
}
|
||||
function loadArtist(uri) {
|
||||
var forceRefetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
var callbackAction = arguments.length > 2 ? arguments[2] : undefined;
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
return {
|
||||
type: 'LOAD_ARTIST',
|
||||
uri: uri,
|
||||
forceRefetch: forceRefetch,
|
||||
callbackAction: callbackAction
|
||||
options: options
|
||||
};
|
||||
}
|
||||
function loadPlaylist(uri) {
|
||||
var forceRefetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
var callbackAction = arguments.length > 2 ? arguments[2] : undefined;
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
return {
|
||||
type: 'LOAD_PLAYLIST',
|
||||
uri: uri,
|
||||
forceRefetch: forceRefetch,
|
||||
callbackAction: callbackAction
|
||||
options: options
|
||||
};
|
||||
}
|
||||
function loadUser(uri) {
|
||||
var forceRefetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
return {
|
||||
type: 'LOAD_USER',
|
||||
uri: uri,
|
||||
forceRefetch: forceRefetch
|
||||
options: options
|
||||
};
|
||||
}
|
||||
function loadUserPlaylists(uri) {
|
||||
var forceRefetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
function loadUserPlaylists(uri, options) {
|
||||
return {
|
||||
type: 'LOAD_USER_PLAYLISTS',
|
||||
uri: uri,
|
||||
forceRefetch: forceRefetch
|
||||
options: options
|
||||
};
|
||||
}
|
||||
function loadLibrary(uri) {
|
||||
var forceRefetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
return {
|
||||
type: 'LOAD_LIBRARY',
|
||||
uri: uri,
|
||||
forceRefetch: forceRefetch
|
||||
options: options
|
||||
};
|
||||
}
|
||||
/**
|
||||
@ -104565,8 +104557,7 @@ var CoreMiddleware = function () {
|
||||
store.dispatch({
|
||||
type: "LOAD_".concat(Object(_util_helpers__WEBPACK_IMPORTED_MODULE_6__["uriType"])(uri).toUpperCase()),
|
||||
uri: uri,
|
||||
forceRefetch: action.forceRefetch,
|
||||
callbackAction: action.callbackAction
|
||||
options: action.options
|
||||
});
|
||||
});
|
||||
break;
|
||||
@ -104576,7 +104567,7 @@ var CoreMiddleware = function () {
|
||||
var fetchTrack = function fetchTrack() {
|
||||
switch (Object(_util_helpers__WEBPACK_IMPORTED_MODULE_6__["uriSource"])(action.uri)) {
|
||||
case 'spotify':
|
||||
store.dispatch(spotifyActions.getTrack(action.uri, action.forceRefetch));
|
||||
store.dispatch(spotifyActions.getTrack(action.uri, action.options));
|
||||
|
||||
if (spotify.me) {
|
||||
store.dispatch(spotifyActions.following(action.uri));
|
||||
@ -104590,7 +104581,7 @@ var CoreMiddleware = function () {
|
||||
}
|
||||
};
|
||||
|
||||
if (action.forceRefetch) {
|
||||
if (action.options.forceRefetch) {
|
||||
console.info("Force-refetching \"".concat(action.uri, "\""));
|
||||
fetchTrack();
|
||||
break;
|
||||
@ -104621,7 +104612,7 @@ var CoreMiddleware = function () {
|
||||
var fetchAlbum = function fetchAlbum() {
|
||||
switch (Object(_util_helpers__WEBPACK_IMPORTED_MODULE_6__["uriSource"])(action.uri)) {
|
||||
case 'spotify':
|
||||
store.dispatch(spotifyActions.getAlbum(action.uri, action.forceRefetch));
|
||||
store.dispatch(spotifyActions.getAlbum(action.uri, action.options));
|
||||
|
||||
if (spotify.me) {
|
||||
store.dispatch(spotifyActions.following(action.uri));
|
||||
@ -104637,13 +104628,13 @@ var CoreMiddleware = function () {
|
||||
;
|
||||
};
|
||||
|
||||
if (action.forceRefetch) {
|
||||
if (action.options.forceRefetch) {
|
||||
console.info("Force-refetching \"".concat(action.uri, "\""));
|
||||
fetchAlbum();
|
||||
break;
|
||||
}
|
||||
|
||||
if (store.getState().core.items[action.uri] && store.getState().core.items[action.uri].tracks) {
|
||||
if (store.getState().core.items[action.uri] && (!action.options.full || store.getState().core.items[action.uri].tracks)) {
|
||||
console.info("Using \"".concat(action.uri, "\" from index"));
|
||||
break;
|
||||
}
|
||||
@ -104667,7 +104658,7 @@ var CoreMiddleware = function () {
|
||||
var fetchArtist = function fetchArtist() {
|
||||
switch (Object(_util_helpers__WEBPACK_IMPORTED_MODULE_6__["uriSource"])(action.uri)) {
|
||||
case 'spotify':
|
||||
store.dispatch(spotifyActions.getArtist(action.uri, true, action.forceRefetch));
|
||||
store.dispatch(spotifyActions.getArtist(action.uri, action.options));
|
||||
|
||||
if (spotify.me) {
|
||||
store.dispatch(spotifyActions.following(action.uri));
|
||||
@ -104681,37 +104672,32 @@ var CoreMiddleware = function () {
|
||||
}
|
||||
};
|
||||
|
||||
if (action.forceRefetch) {
|
||||
if (action.options.forceRefetch) {
|
||||
console.info("Force-refetching \"".concat(action.uri, "\""));
|
||||
fetchArtist();
|
||||
break;
|
||||
}
|
||||
|
||||
if (store.getState().core.items[action.uri] && store.getState().core.items[action.uri].tracks && store.getState().core.items[action.uri].albums_uris && store.getState().core.items[action.uri].images) {
|
||||
if (store.getState().core.items[action.uri] && (!action.options.full || store.getState().core.items[action.uri].tracks && store.getState().core.items[action.uri].albums_uris && store.getState().core.items[action.uri].images)) {
|
||||
console.info("Using \"".concat(action.uri, "\" from index"));
|
||||
break;
|
||||
}
|
||||
|
||||
localforage__WEBPACK_IMPORTED_MODULE_2___default.a.getItem(action.uri).then(function (artist) {
|
||||
if (artist) {
|
||||
console.info("Restoring \"".concat(action.uri, "\" and ").concat(artist.albums_uris.length, " albums from database"));
|
||||
console.info("Restoring \"".concat(action.uri, "\" and ").concat(artist.albums_uris ? artist.albums_uris.length : 0, " albums from database"));
|
||||
store.dispatch(coreActions.restoreItemsFromColdStore([artist]));
|
||||
|
||||
if (artist.albums_uris) {
|
||||
var promises = artist.albums_uris.map(function (albumUri) {
|
||||
return localforage__WEBPACK_IMPORTED_MODULE_2___default.a.getItem(albumUri);
|
||||
});
|
||||
Promise.all(promises).then(function (albums) {
|
||||
return store.dispatch(coreActions.restoreItemsFromColdStore(Object(lodash__WEBPACK_IMPORTED_MODULE_3__["compact"])(albums)));
|
||||
});
|
||||
store.dispatch(coreActions.restoreLibraryFromColdStore(artist));
|
||||
} else {
|
||||
fetchArtist();
|
||||
}
|
||||
});
|
||||
localforage__WEBPACK_IMPORTED_MODULE_2___default.a.getItem(action.uri).then(function (result) {
|
||||
if (result) {
|
||||
console.info("Restoring \"".concat(action.uri, "\" from database"));
|
||||
store.dispatch(coreActions.restoreItemsFromColdStore([result]));
|
||||
|
||||
if (!result.tracks || !result.albums_uris || !result.images) {
|
||||
if (action.options.full && (!artist.tracks || !artist.albums_uris || !artist.images)) {
|
||||
fetchArtist();
|
||||
}
|
||||
} else {
|
||||
@ -104725,7 +104711,7 @@ var CoreMiddleware = function () {
|
||||
var fetchPlaylist = function fetchPlaylist() {
|
||||
switch (Object(_util_helpers__WEBPACK_IMPORTED_MODULE_6__["uriSource"])(action.uri)) {
|
||||
case 'spotify':
|
||||
store.dispatch(spotifyActions.getPlaylist(action.uri, action.forceRefetch));
|
||||
store.dispatch(spotifyActions.getPlaylist(action.uri, action.options));
|
||||
|
||||
if (spotify.me) {
|
||||
store.dispatch(spotifyActions.following(action.uri));
|
||||
@ -104739,13 +104725,13 @@ var CoreMiddleware = function () {
|
||||
}
|
||||
};
|
||||
|
||||
if (action.forceRefetch) {
|
||||
if (action.options.forceRefetch) {
|
||||
console.info("Force-refetching \"".concat(action.uri, "\""));
|
||||
fetchPlaylist();
|
||||
break;
|
||||
}
|
||||
|
||||
if (store.getState().core.items[action.uri] && store.getState().core.items[action.uri].tracks) {
|
||||
if (store.getState().core.items[action.uri] && (!action.options.full || store.getState().core.items[action.uri].tracks)) {
|
||||
console.info("Using \"".concat(action.uri, "\" from index"));
|
||||
break;
|
||||
}
|
||||
@ -104755,7 +104741,7 @@ var CoreMiddleware = function () {
|
||||
console.info("Restoring \"".concat(action.uri, "\" from database"));
|
||||
store.dispatch(coreActions.restoreItemsFromColdStore([result]));
|
||||
|
||||
if (!result.tracks) {
|
||||
if (!action.options.full || !result.tracks) {
|
||||
fetchPlaylist();
|
||||
}
|
||||
} else {
|
||||
@ -104766,7 +104752,7 @@ var CoreMiddleware = function () {
|
||||
break;
|
||||
|
||||
case 'LOAD_USER':
|
||||
if (!action.forceRefetch && store.getState().core.users[action.uri] && store.getState().core.users[action.uri].playlists_uris) {
|
||||
if (!action.options.forceRefetch && store.getState().core.users[action.uri] && store.getState().core.users[action.uri].playlists_uris) {
|
||||
console.info("Loading \"".concat(action.uri, "\" from index"));
|
||||
break;
|
||||
}
|
||||
@ -104790,7 +104776,7 @@ var CoreMiddleware = function () {
|
||||
break;
|
||||
|
||||
case 'LOAD_USER_PLAYLISTS':
|
||||
if (!action.forceRefetch && store.getState().core.users[action.uri] && store.getState().core.users[action.uri].playlists_uris) {
|
||||
if (!action.options.forceRefetch && store.getState().core.users[action.uri] && store.getState().core.users[action.uri].playlists_uris) {
|
||||
console.info("Loading \"".concat(action.uri, "\" playlists from index"));
|
||||
break;
|
||||
}
|
||||
@ -104825,7 +104811,7 @@ var CoreMiddleware = function () {
|
||||
}
|
||||
};
|
||||
|
||||
if (action.forceRefetch) {
|
||||
if (action.options.forceRefetch) {
|
||||
console.info("Force-refetching \"".concat(action.uri, "\""));
|
||||
fetchLibrary();
|
||||
break;
|
||||
@ -108536,7 +108522,7 @@ var MopidyMiddleware = function () {
|
||||
break;
|
||||
}
|
||||
|
||||
store.dispatch(coreActions.loadPlaylist(action.uri, false, {
|
||||
store.dispatch(coreActions.loadItem(action.uri, false, {
|
||||
name: 'play',
|
||||
shuffle: action.shuffle
|
||||
}));
|
||||
@ -108552,7 +108538,7 @@ var MopidyMiddleware = function () {
|
||||
break;
|
||||
}
|
||||
|
||||
store.dispatch(coreActions.loadPlaylist(action.uri, false, {
|
||||
store.dispatch(coreActions.loadItem(action.uri, false, {
|
||||
name: 'enqueue',
|
||||
shuffle: action.shuffle,
|
||||
play_next: action.play_next,
|
||||
@ -113455,9 +113441,9 @@ function getGenres() {
|
||||
* @param full boolean (whether we want a full artist object)
|
||||
* */
|
||||
|
||||
function getArtist(uri) {
|
||||
var full = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
var forceRefetch = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
||||
function getArtist(uri, _ref) {
|
||||
var full = _ref.full,
|
||||
forceRefetch = _ref.forceRefetch;
|
||||
return function (dispatch, getState) {
|
||||
var endpoint = "artists/".concat(Object(_util_helpers__WEBPACK_IMPORTED_MODULE_2__["getFromUri"])('artistid', uri)).concat(forceRefetch ? "?refetch=".concat(Date.now()) : '');
|
||||
request(dispatch, getState, endpoint, 'GET', false, true).then(function (response) {
|
||||
@ -113595,13 +113581,15 @@ function getUserPlaylists(uri) {
|
||||
* @oaram uri string
|
||||
* */
|
||||
|
||||
function getAlbum(uri, forceRefetch) {
|
||||
function getAlbum(uri, _ref2) {
|
||||
var full = _ref2.full,
|
||||
forceRefetch = _ref2.forceRefetch;
|
||||
return function (dispatch, getState) {
|
||||
var endpoint = "albums/".concat(Object(_util_helpers__WEBPACK_IMPORTED_MODULE_2__["getFromUri"])('albumid', uri)).concat(forceRefetch ? "?refetch=".concat(Date.now()) : '');
|
||||
request(dispatch, getState, endpoint).then(function (response) {
|
||||
dispatch(coreActions.itemLoaded(_objectSpread(_objectSpread({}, Object(_util_format__WEBPACK_IMPORTED_MODULE_3__["formatAlbum"])(response)), {}, {
|
||||
tracks: Object(_util_format__WEBPACK_IMPORTED_MODULE_3__["formatTracks"])(response.tracks.items)
|
||||
})));
|
||||
dispatch(coreActions.itemLoaded(_objectSpread({}, Object(_util_format__WEBPACK_IMPORTED_MODULE_3__["formatAlbum"])(response))));
|
||||
|
||||
if (full) {
|
||||
var tracks = Object(_util_format__WEBPACK_IMPORTED_MODULE_3__["formatTracks"])(response.tracks.items);
|
||||
|
||||
var fetchTracks = function fetchTracks(endpoint) {
|
||||
@ -113622,6 +113610,7 @@ function getAlbum(uri, forceRefetch) {
|
||||
if (response.tracks.next) {
|
||||
fetchTracks(response.tracks.next);
|
||||
}
|
||||
}
|
||||
}, function (error) {
|
||||
dispatch(coreActions.handleException('Could not load album', error));
|
||||
});
|
||||
@ -113704,9 +113693,10 @@ function savePlaylist(uri, name, description, is_public, is_collaborative, image
|
||||
});
|
||||
};
|
||||
}
|
||||
function getPlaylist(uri) {
|
||||
var forceRefetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
var callbackAction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
||||
function getPlaylist(uri, _ref3) {
|
||||
var full = _ref3.full,
|
||||
forceRefetch = _ref3.forceRefetch,
|
||||
callbackAction = _ref3.callbackAction;
|
||||
return function (dispatch, getState) {
|
||||
var endpoint = "playlists/".concat(Object(_util_helpers__WEBPACK_IMPORTED_MODULE_2__["getFromUri"])('playlistid', uri), "?market=").concat(getState().spotify.country).concat(forceRefetch ? "&refetch=".concat(Date.now()) : '');
|
||||
request(dispatch, getState, endpoint).then(function (response) {
|
||||
@ -113723,10 +113713,10 @@ function getPlaylist(uri) {
|
||||
|
||||
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,
|
||||
tracks: tracks,
|
||||
description: description
|
||||
})));
|
||||
|
||||
if (full) {
|
||||
var fetchTracks = function fetchTracks(endpoint) {
|
||||
return request(dispatch, getState, endpoint).then(function (response) {
|
||||
tracks = [].concat(_toConsumableArray(tracks), _toConsumableArray(Object(_util_format__WEBPACK_IMPORTED_MODULE_3__["formatTracks"])(response.items)));
|
||||
@ -113760,6 +113750,9 @@ function getPlaylist(uri) {
|
||||
if (response.tracks.next) {
|
||||
fetchTracks(response.tracks.next);
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
}, function (error) {
|
||||
dispatch(coreActions.handleException('Could not load playlist', error));
|
||||
});
|
||||
@ -114012,7 +114005,8 @@ function getLibraryPlaylists(forceRefetch) {
|
||||
return request(dispatch, getState, endpoint).then(function (response) {
|
||||
var items = response.items.map(function (item) {
|
||||
return _objectSpread(_objectSpread({}, item), {}, {
|
||||
in_library: true
|
||||
in_library: true,
|
||||
can_edit: getState().spotify.me && item.owner.id === getState().spotify.me.id
|
||||
});
|
||||
});
|
||||
libraryItems = [].concat(_toConsumableArray(libraryItems), _toConsumableArray(Object(_util_format__WEBPACK_IMPORTED_MODULE_3__["formatPlaylists"])(items)));
|
||||
@ -118645,8 +118639,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _services_spotify_actions__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../services/spotify/actions */ "./src/js/services/spotify/actions.js");
|
||||
/* harmony import */ var _services_lastfm_actions__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../services/lastfm/actions */ "./src/js/services/lastfm/actions.js");
|
||||
/* harmony import */ var _util_helpers__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../util/helpers */ "./src/js/util/helpers.js");
|
||||
/* harmony import */ var _util_format__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../util/format */ "./src/js/util/format.js");
|
||||
/* harmony import */ var _components_Button__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../components/Button */ "./src/js/components/Button.js");
|
||||
/* harmony import */ var _components_Button__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../components/Button */ "./src/js/components/Button.js");
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
@ -118687,7 +118680,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var Album = /*#__PURE__*/function (_React$Component) {
|
||||
@ -118710,12 +118702,14 @@ var Album = /*#__PURE__*/function (_React$Component) {
|
||||
var _this$props = _this.props,
|
||||
uri = _this$props.uri,
|
||||
album = _this$props.album,
|
||||
loadAlbum = _this$props.coreActions.loadAlbum,
|
||||
loadItem = _this$props.coreActions.loadItem,
|
||||
getAlbum = _this$props.lastfmActions.getAlbum;
|
||||
|
||||
_this.setWindowTitle();
|
||||
|
||||
loadAlbum(uri);
|
||||
loadItem(uri, {
|
||||
full: true
|
||||
});
|
||||
|
||||
if (album) {
|
||||
if (album.artists && album.wiki === undefined) {
|
||||
@ -118741,11 +118735,13 @@ var Album = /*#__PURE__*/function (_React$Component) {
|
||||
var _this$props3 = _this.props,
|
||||
uri = _this$props3.uri,
|
||||
album = _this$props3.album,
|
||||
loadAlbum = _this$props3.coreActions.loadAlbum,
|
||||
loadItem = _this$props3.coreActions.loadItem,
|
||||
getAlbum = _this$props3.lastfmActions.getAlbum;
|
||||
|
||||
if (uri !== prevUri) {
|
||||
loadAlbum(uri);
|
||||
loadItem(uri, {
|
||||
full: true
|
||||
});
|
||||
} // We have just received our full album or our album artists
|
||||
|
||||
|
||||
@ -118940,7 +118936,7 @@ var Album = /*#__PURE__*/function (_React$Component) {
|
||||
className: "actions",
|
||||
"data-qa-node": "div",
|
||||
"data-qa-file": "Album"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_Button__WEBPACK_IMPORTED_MODULE_22__["default"], {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_components_Button__WEBPACK_IMPORTED_MODULE_21__["default"], {
|
||||
type: "primary",
|
||||
onClick: _this.play,
|
||||
tracking: {
|
||||
@ -119152,10 +119148,12 @@ var Artist = /*#__PURE__*/function (_React$Component) {
|
||||
var _this$props = _this.props,
|
||||
uri = _this$props.uri,
|
||||
artist = _this$props.artist,
|
||||
loadArtist = _this$props.coreActions.loadArtist;
|
||||
loadItem = _this$props.coreActions.loadItem;
|
||||
|
||||
if (uri !== prevUri) {
|
||||
loadArtist(uri);
|
||||
loadItem(uri, {
|
||||
full: true
|
||||
});
|
||||
}
|
||||
|
||||
if (!prevArtist && artist) _this.setWindowTitle(artist);
|
||||
@ -119824,7 +119822,9 @@ var Artist = /*#__PURE__*/function (_React$Component) {
|
||||
key: "componentDidMount",
|
||||
value: function componentDidMount() {
|
||||
this.setWindowTitle();
|
||||
this.props.coreActions.loadArtist(this.props.uri);
|
||||
this.props.coreActions.loadItem(this.props.uri, {
|
||||
full: true
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
@ -120683,8 +120683,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _services_mopidy_actions__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../services/mopidy/actions */ "./src/js/services/mopidy/actions.js");
|
||||
/* harmony import */ var _services_spotify_actions__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../services/spotify/actions */ "./src/js/services/spotify/actions.js");
|
||||
/* harmony import */ var _util_helpers__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../util/helpers */ "./src/js/util/helpers.js");
|
||||
/* harmony import */ var _util_format__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../util/format */ "./src/js/util/format.js");
|
||||
/* harmony import */ var _locale__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../locale */ "./src/js/locale/index.js");
|
||||
/* harmony import */ var _locale__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../locale */ "./src/js/locale/index.js");
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
@ -120730,7 +120729,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
@ -120759,7 +120757,9 @@ var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
}
|
||||
|
||||
if (uri !== prevUri) {
|
||||
loadItem(uri);
|
||||
loadItem(uri, {
|
||||
full: true
|
||||
});
|
||||
}
|
||||
|
||||
if (!prevPlaylist && playlist) _this.setWindowTitle(playlist);
|
||||
@ -120769,9 +120769,9 @@ var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
_defineProperty(_assertThisInitialized(_this), "setWindowTitle", function () {
|
||||
var playlist = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props.playlist;
|
||||
var setWindowTitle = _this.props.uiActions.setWindowTitle;
|
||||
setWindowTitle(playlist ? Object(_locale__WEBPACK_IMPORTED_MODULE_22__["i18n"])('playlist.title_window', {
|
||||
setWindowTitle(playlist ? Object(_locale__WEBPACK_IMPORTED_MODULE_21__["i18n"])('playlist.title_window', {
|
||||
name: playlist.name
|
||||
}) : Object(_locale__WEBPACK_IMPORTED_MODULE_22__["i18n"])('playlist.title'));
|
||||
}) : Object(_locale__WEBPACK_IMPORTED_MODULE_21__["i18n"])('playlist.title'));
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "handleContextMenu", function (e) {
|
||||
@ -120862,7 +120862,7 @@ var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
},
|
||||
"data-qa-node": "Button",
|
||||
"data-qa-file": "Playlist"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_22__["I18n"], {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_21__["I18n"], {
|
||||
path: "actions.play",
|
||||
"data-qa-node": "I18n",
|
||||
"data-qa-file": "Playlist"
|
||||
@ -120874,7 +120874,7 @@ var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
},
|
||||
"data-qa-node": "Button",
|
||||
"data-qa-file": "Playlist"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_22__["I18n"], {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_21__["I18n"], {
|
||||
path: "actions.edit",
|
||||
"data-qa-node": "I18n",
|
||||
"data-qa-file": "Playlist"
|
||||
@ -120906,7 +120906,7 @@ var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
},
|
||||
"data-qa-node": "Button",
|
||||
"data-qa-file": "Playlist"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_22__["I18n"], {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_21__["I18n"], {
|
||||
path: "actions.play",
|
||||
"data-qa-node": "I18n",
|
||||
"data-qa-file": "Playlist"
|
||||
@ -120918,7 +120918,7 @@ var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
},
|
||||
"data-qa-node": "Button",
|
||||
"data-qa-file": "Playlist"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_22__["I18n"], {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_21__["I18n"], {
|
||||
path: "actions.edit",
|
||||
"data-qa-node": "I18n",
|
||||
"data-qa-file": "Playlist"
|
||||
@ -120949,7 +120949,7 @@ var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
},
|
||||
"data-qa-node": "Button",
|
||||
"data-qa-file": "Playlist"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_22__["I18n"], {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_21__["I18n"], {
|
||||
path: "actions.play",
|
||||
"data-qa-node": "I18n",
|
||||
"data-qa-file": "Playlist"
|
||||
@ -120985,7 +120985,7 @@ var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
},
|
||||
"data-qa-node": "Button",
|
||||
"data-qa-file": "Playlist"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_22__["I18n"], {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_21__["I18n"], {
|
||||
path: "actions.play",
|
||||
"data-qa-node": "I18n",
|
||||
"data-qa-file": "Playlist"
|
||||
@ -121030,7 +121030,7 @@ var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("p", {
|
||||
"data-qa-node": "p",
|
||||
"data-qa-file": "Playlist"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_22__["I18n"], {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_21__["I18n"], {
|
||||
path: "errors.uri_not_found",
|
||||
uri: uri,
|
||||
"data-qa-node": "I18n",
|
||||
@ -121098,9 +121098,9 @@ var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
}, playlist.user.name)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("li", {
|
||||
"data-qa-node": "li",
|
||||
"data-qa-file": "Playlist"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_22__["I18n"], {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_21__["I18n"], {
|
||||
path: "specs.tracks",
|
||||
count: playlist.tracks_total || 0,
|
||||
count: playlist.tracks ? playlist.tracks.length : 0,
|
||||
"data-qa-node": "I18n",
|
||||
"data-qa-file": "Playlist"
|
||||
})), !slim_mode && playlist.tracks && playlist.tracks_total > 0 && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("li", {
|
||||
@ -121114,7 +121114,7 @@ var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
})), !slim_mode && playlist.followers !== undefined && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("li", {
|
||||
"data-qa-node": "li",
|
||||
"data-qa-file": "Playlist"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_22__["I18n"], {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_21__["I18n"], {
|
||||
path: "specs.followers",
|
||||
count: Object(_components_NiceNumber__WEBPACK_IMPORTED_MODULE_8__["nice_number"])(playlist.followers),
|
||||
"data-qa-node": "I18n",
|
||||
@ -121122,7 +121122,7 @@ var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
})), !slim_mode && playlist.last_modified_date && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("li", {
|
||||
"data-qa-node": "li",
|
||||
"data-qa-file": "Playlist"
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_22__["I18n"], {
|
||||
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_locale__WEBPACK_IMPORTED_MODULE_21__["I18n"], {
|
||||
path: "specs.edited",
|
||||
date: Object(_components_Dater__WEBPACK_IMPORTED_MODULE_9__["dater"])('ago', playlist.last_modified_date),
|
||||
"data-qa-node": "I18n",
|
||||
@ -121166,7 +121166,9 @@ var Playlist = /*#__PURE__*/function (_React$Component) {
|
||||
loadItem = _this$props10.coreActions.loadItem,
|
||||
uri = _this$props10.uri;
|
||||
this.setWindowTitle();
|
||||
loadItem(uri);
|
||||
loadItem(uri, {
|
||||
full: true
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
@ -123676,12 +123678,12 @@ var Track = /*#__PURE__*/function (_React$Component) {
|
||||
track = _this$props.track,
|
||||
genius_authorized = _this$props.genius_authorized,
|
||||
lastfm_authorized = _this$props.lastfm_authorized,
|
||||
loadTrack = _this$props.coreActions.loadTrack,
|
||||
loadItem = _this$props.coreActions.loadItem,
|
||||
findTrackLyrics = _this$props.geniusActions.findTrackLyrics,
|
||||
getTrack = _this$props.lastfmActions.getTrack;
|
||||
|
||||
if (prevUri !== uri) {
|
||||
loadTrack(uri);
|
||||
loadItem(uri);
|
||||
|
||||
if (genius_authorized && track.artists) {
|
||||
findTrackLyrics(track);
|
||||
@ -124066,10 +124068,10 @@ var Track = /*#__PURE__*/function (_React$Component) {
|
||||
var _this$props7 = this.props,
|
||||
uri = _this$props7.uri,
|
||||
track = _this$props7.track,
|
||||
loadTrack = _this$props7.coreActions.loadTrack,
|
||||
loadItem = _this$props7.coreActions.loadItem,
|
||||
genius_authorized = _this$props7.genius_authorized,
|
||||
findTrackLyrics = _this$props7.geniusActions.findTrackLyrics;
|
||||
loadTrack(uri);
|
||||
loadItem(uri);
|
||||
|
||||
if (track) {
|
||||
this.setWindowTitle(track);
|
||||
@ -126840,7 +126842,9 @@ var LibraryArtists = /*#__PURE__*/function (_React$Component) {
|
||||
source = _this$props2.source,
|
||||
loadLibrary = _this$props2.coreActions.loadLibrary;
|
||||
if (source !== 'local' && source !== 'all') return;
|
||||
loadLibrary('mopidy:library:artists', forceRefetch);
|
||||
loadLibrary('mopidy:library:artists', {
|
||||
forceRefetch: forceRefetch
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "getGoogleLibrary", function () {
|
||||
@ -126851,7 +126855,9 @@ var LibraryArtists = /*#__PURE__*/function (_React$Component) {
|
||||
loadLibrary = _this$props3.coreActions.loadLibrary;
|
||||
if (!google_available) return;
|
||||
if (source !== 'google' && source !== 'all') return;
|
||||
loadLibrary('google:library:artists', forceRefetch);
|
||||
loadLibrary('google:library:artists', {
|
||||
forceRefetch: forceRefetch
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "getSpotifyLibrary", function () {
|
||||
@ -126862,7 +126868,9 @@ var LibraryArtists = /*#__PURE__*/function (_React$Component) {
|
||||
loadLibrary = _this$props4.coreActions.loadLibrary;
|
||||
if (!spotify_available) return;
|
||||
if (source !== 'spotify' && source !== 'all') return;
|
||||
loadLibrary('spotify:library:artists', forceRefetch);
|
||||
loadLibrary('spotify:library:artists', {
|
||||
forceRefetch: forceRefetch
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "loadMore", function () {
|
||||
@ -127950,7 +127958,9 @@ var LibraryPlaylists = /*#__PURE__*/function (_React$Component) {
|
||||
source = _this$props.source,
|
||||
loadLibrary = _this$props.coreActions.loadLibrary;
|
||||
if (source !== 'local' && source !== 'all') return;
|
||||
loadLibrary('mopidy:library:playlists', forceRefetch);
|
||||
loadLibrary('mopidy:library:playlists', {
|
||||
forceRefetch: forceRefetch
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "getSpotifyLibrary", function () {
|
||||
@ -127961,7 +127971,9 @@ var LibraryPlaylists = /*#__PURE__*/function (_React$Component) {
|
||||
loadLibrary = _this$props2.coreActions.loadLibrary;
|
||||
if (!spotify_available) return;
|
||||
if (source !== 'spotify' && source !== 'all') return;
|
||||
loadLibrary('spotify:library:playlists', forceRefetch);
|
||||
loadLibrary('spotify:library:playlists', {
|
||||
forceRefetch: forceRefetch
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(_assertThisInitialized(_this), "componentDidUpdate", function (_ref) {
|
||||
|
||||
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 = "1599594817";
|
||||
var build = "1599594930";
|
||||
var version = "3.52.4";
|
||||
|
||||
// Construct the script tag
|
||||
|
||||
@ -626,7 +626,7 @@ class ContextMenu extends React.Component {
|
||||
|
||||
const uri = uris[0];
|
||||
|
||||
loadItem(uri, true);
|
||||
loadItem(uri, { forceRefetch: true });
|
||||
hideContextMenu();
|
||||
}
|
||||
|
||||
@ -1297,13 +1297,13 @@ const mapStateToProps = (state) => ({
|
||||
current_tracklist: state.core.current_tracklist,
|
||||
queue_metadata: state.core.queue_metadata,
|
||||
spotify_available: state.spotify.access_token,
|
||||
spotify_library_playlists: state.core.items['spotify:library:playlists'] || { items_uris: [] },
|
||||
spotify_library_artists: state.core.items['spotify:library:artists'] || { items_uris: [] },
|
||||
spotify_library_albums: state.core.items['spotify:library:albums'] || { items_uris: [] },
|
||||
spotify_library_playlists: state.core.libraries['spotify:library:playlists'] || { items_uris: [] },
|
||||
spotify_library_artists: state.core.libraries['spotify:library:artists'] || { items_uris: [] },
|
||||
spotify_library_albums: state.core.libraries['spotify:library:albums'] || { items_uris: [] },
|
||||
spotify_library_tracks: state.spotify.library_tracks,
|
||||
mopidy_library_playlists: state.core.items['mopidy:library:playlists'] || { items_uris: [] },
|
||||
mopidy_library_artists: state.core.items['mopidy:library:artists'] || { items_uris: [] },
|
||||
mopidy_library_albums: state.core.items['mopidy:library:albums'] || { items_uris: [] },
|
||||
mopidy_library_playlists: state.core.libraries['mopidy:library:playlists'] || { items_uris: [] },
|
||||
mopidy_library_artists: state.core.libraries['mopidy:library:artists'] || { items_uris: [] },
|
||||
mopidy_library_albums: state.core.libraries['mopidy:library:albums'] || { items_uris: [] },
|
||||
playlists: state.core.playlists,
|
||||
tracks: state.core.tracks,
|
||||
items: state.core.items,
|
||||
|
||||
@ -107,75 +107,71 @@ export function updateColdStore(items) {
|
||||
* relevant service to load the record - all from one neat package.
|
||||
* */
|
||||
|
||||
export function loadItems(uris, forceRefetch = false, callbackAction = null) {
|
||||
export function loadItems(uris, options = {}) {
|
||||
return {
|
||||
type: 'LOAD_ITEMS',
|
||||
uris,
|
||||
forceRefetch,
|
||||
callbackAction,
|
||||
options,
|
||||
};
|
||||
}
|
||||
|
||||
export function loadItem(uri, forceRefetch = false, callbackAction) {
|
||||
return loadItems([uri], forceRefetch, callbackAction);
|
||||
export function loadItem(uri, options = {}) {
|
||||
return loadItems([uri], options);
|
||||
}
|
||||
|
||||
export function loadTrack(uri, forceRefetch = false) {
|
||||
export function loadTrack(uri, options = {}) {
|
||||
return {
|
||||
type: 'LOAD_TRACK',
|
||||
uri,
|
||||
forceRefetch,
|
||||
options,
|
||||
};
|
||||
}
|
||||
|
||||
export function loadAlbum(uri, forceRefetch = false, callbackAction) {
|
||||
export function loadAlbum(uri, options = {}) {
|
||||
return {
|
||||
type: 'LOAD_ALBUM',
|
||||
uri,
|
||||
forceRefetch,
|
||||
callbackAction,
|
||||
options,
|
||||
};
|
||||
}
|
||||
|
||||
export function loadArtist(uri, forceRefetch = false, callbackAction) {
|
||||
export function loadArtist(uri, options = {}) {
|
||||
return {
|
||||
type: 'LOAD_ARTIST',
|
||||
uri,
|
||||
forceRefetch,
|
||||
callbackAction,
|
||||
options,
|
||||
};
|
||||
}
|
||||
|
||||
export function loadPlaylist(uri, forceRefetch = false, callbackAction) {
|
||||
export function loadPlaylist(uri, options = {}) {
|
||||
return {
|
||||
type: 'LOAD_PLAYLIST',
|
||||
uri,
|
||||
forceRefetch,
|
||||
callbackAction,
|
||||
options,
|
||||
};
|
||||
}
|
||||
|
||||
export function loadUser(uri, forceRefetch = false) {
|
||||
export function loadUser(uri, options = {}) {
|
||||
return {
|
||||
type: 'LOAD_USER',
|
||||
uri,
|
||||
forceRefetch,
|
||||
options,
|
||||
};
|
||||
}
|
||||
|
||||
export function loadUserPlaylists(uri, forceRefetch = false) {
|
||||
export function loadUserPlaylists(uri, options) {
|
||||
return {
|
||||
type: 'LOAD_USER_PLAYLISTS',
|
||||
uri,
|
||||
forceRefetch,
|
||||
options,
|
||||
};
|
||||
}
|
||||
|
||||
export function loadLibrary(uri, forceRefetch = false) {
|
||||
export function loadLibrary(uri, options = {}) {
|
||||
return {
|
||||
type: 'LOAD_LIBRARY',
|
||||
uri,
|
||||
forceRefetch,
|
||||
options,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -318,8 +318,7 @@ const CoreMiddleware = (function () {
|
||||
store.dispatch({
|
||||
type: `LOAD_${uriType(uri).toUpperCase()}`,
|
||||
uri,
|
||||
forceRefetch: action.forceRefetch,
|
||||
callbackAction: action.callbackAction,
|
||||
options: action.options,
|
||||
});
|
||||
});
|
||||
break;
|
||||
@ -328,7 +327,7 @@ const CoreMiddleware = (function () {
|
||||
const fetchTrack = () => {
|
||||
switch (uriSource(action.uri)) {
|
||||
case 'spotify':
|
||||
store.dispatch(spotifyActions.getTrack(action.uri, action.forceRefetch));
|
||||
store.dispatch(spotifyActions.getTrack(action.uri, action.options));
|
||||
|
||||
if (spotify.me) {
|
||||
store.dispatch(spotifyActions.following(action.uri));
|
||||
@ -341,7 +340,7 @@ const CoreMiddleware = (function () {
|
||||
}
|
||||
};
|
||||
|
||||
if (action.forceRefetch) {
|
||||
if (action.options.forceRefetch) {
|
||||
console.info(`Force-refetching "${action.uri}"`);
|
||||
fetchTrack();
|
||||
break;
|
||||
@ -375,7 +374,7 @@ const CoreMiddleware = (function () {
|
||||
const fetchAlbum = () => {
|
||||
switch (uriSource(action.uri)) {
|
||||
case 'spotify':
|
||||
store.dispatch(spotifyActions.getAlbum(action.uri, action.forceRefetch));
|
||||
store.dispatch(spotifyActions.getAlbum(action.uri, action.options));
|
||||
|
||||
if (spotify.me) {
|
||||
store.dispatch(spotifyActions.following(action.uri));
|
||||
@ -388,14 +387,14 @@ const CoreMiddleware = (function () {
|
||||
};
|
||||
};
|
||||
|
||||
if (action.forceRefetch) {
|
||||
if (action.options.forceRefetch) {
|
||||
console.info(`Force-refetching "${action.uri}"`);
|
||||
fetchAlbum();
|
||||
break;
|
||||
}
|
||||
if (
|
||||
store.getState().core.items[action.uri]
|
||||
&& store.getState().core.items[action.uri].tracks
|
||||
&& (!action.options.full || store.getState().core.items[action.uri].tracks)
|
||||
) {
|
||||
console.info(`Using "${action.uri}" from index`);
|
||||
break;
|
||||
@ -422,7 +421,7 @@ const CoreMiddleware = (function () {
|
||||
const fetchArtist = () => {
|
||||
switch (uriSource(action.uri)) {
|
||||
case 'spotify':
|
||||
store.dispatch(spotifyActions.getArtist(action.uri, true, action.forceRefetch));
|
||||
store.dispatch(spotifyActions.getArtist(action.uri, action.options));
|
||||
|
||||
if (spotify.me) {
|
||||
store.dispatch(spotifyActions.following(action.uri));
|
||||
@ -435,16 +434,21 @@ const CoreMiddleware = (function () {
|
||||
}
|
||||
};
|
||||
|
||||
if (action.forceRefetch) {
|
||||
if (action.options.forceRefetch) {
|
||||
console.info(`Force-refetching "${action.uri}"`);
|
||||
fetchArtist();
|
||||
break;
|
||||
}
|
||||
if (
|
||||
store.getState().core.items[action.uri]
|
||||
&& store.getState().core.items[action.uri].tracks
|
||||
&& (
|
||||
!action.options.full
|
||||
|| (
|
||||
store.getState().core.items[action.uri].tracks
|
||||
&& store.getState().core.items[action.uri].albums_uris
|
||||
&& store.getState().core.items[action.uri].images
|
||||
)
|
||||
)
|
||||
) {
|
||||
console.info(`Using "${action.uri}" from index`);
|
||||
break;
|
||||
@ -452,25 +456,17 @@ const CoreMiddleware = (function () {
|
||||
|
||||
localForage.getItem(action.uri).then((artist) => {
|
||||
if (artist) {
|
||||
console.info(`Restoring "${action.uri}" and ${artist.albums_uris.length} albums from database`);
|
||||
console.info(`Restoring "${action.uri}" and ${artist.albums_uris ? artist.albums_uris.length : 0} albums from database`);
|
||||
store.dispatch(coreActions.restoreItemsFromColdStore([artist]));
|
||||
|
||||
if (artist.albums_uris) {
|
||||
const promises = artist.albums_uris.map((albumUri) => localForage.getItem(albumUri));
|
||||
Promise.all(promises).then(
|
||||
(albums) => store.dispatch(coreActions.restoreItemsFromColdStore(compact(albums))),
|
||||
);
|
||||
|
||||
store.dispatch(coreActions.restoreLibraryFromColdStore(artist));
|
||||
} else {
|
||||
fetchArtist();
|
||||
}
|
||||
});
|
||||
|
||||
localForage.getItem(action.uri).then((result) => {
|
||||
if (result) {
|
||||
console.info(`Restoring "${action.uri}" from database`);
|
||||
store.dispatch(coreActions.restoreItemsFromColdStore([result]));
|
||||
|
||||
if (!result.tracks || !result.albums_uris || !result.images) {
|
||||
if (action.options.full && (!artist.tracks || !artist.albums_uris || !artist.images)) {
|
||||
fetchArtist();
|
||||
}
|
||||
} else {
|
||||
@ -485,7 +481,7 @@ const CoreMiddleware = (function () {
|
||||
const fetchPlaylist = () => {
|
||||
switch (uriSource(action.uri)) {
|
||||
case 'spotify':
|
||||
store.dispatch(spotifyActions.getPlaylist(action.uri, action.forceRefetch));
|
||||
store.dispatch(spotifyActions.getPlaylist(action.uri, action.options));
|
||||
|
||||
if (spotify.me) {
|
||||
store.dispatch(spotifyActions.following(action.uri));
|
||||
@ -498,14 +494,17 @@ const CoreMiddleware = (function () {
|
||||
}
|
||||
};
|
||||
|
||||
if (action.forceRefetch) {
|
||||
if (action.options.forceRefetch) {
|
||||
console.info(`Force-refetching "${action.uri}"`);
|
||||
fetchPlaylist();
|
||||
break;
|
||||
}
|
||||
if (
|
||||
store.getState().core.items[action.uri]
|
||||
&& store.getState().core.items[action.uri].tracks
|
||||
&& (
|
||||
!action.options.full
|
||||
|| store.getState().core.items[action.uri].tracks
|
||||
)
|
||||
) {
|
||||
console.info(`Using "${action.uri}" from index`);
|
||||
break;
|
||||
@ -515,7 +514,7 @@ const CoreMiddleware = (function () {
|
||||
if (result) {
|
||||
console.info(`Restoring "${action.uri}" from database`);
|
||||
store.dispatch(coreActions.restoreItemsFromColdStore([result]));
|
||||
if (!result.tracks) {
|
||||
if (!action.options.full || !result.tracks) {
|
||||
fetchPlaylist();
|
||||
}
|
||||
} else {
|
||||
@ -528,7 +527,7 @@ const CoreMiddleware = (function () {
|
||||
|
||||
case 'LOAD_USER':
|
||||
if (
|
||||
!action.forceRefetch
|
||||
!action.options.forceRefetch
|
||||
&& store.getState().core.users[action.uri]
|
||||
&& store.getState().core.users[action.uri].playlists_uris) {
|
||||
console.info(`Loading "${action.uri}" from index`);
|
||||
@ -554,7 +553,7 @@ const CoreMiddleware = (function () {
|
||||
|
||||
case 'LOAD_USER_PLAYLISTS':
|
||||
if (
|
||||
!action.forceRefetch
|
||||
!action.options.forceRefetch
|
||||
&& store.getState().core.users[action.uri]
|
||||
&& store.getState().core.users[action.uri].playlists_uris) {
|
||||
console.info(`Loading "${action.uri}" playlists from index`);
|
||||
@ -595,7 +594,7 @@ const CoreMiddleware = (function () {
|
||||
}
|
||||
};
|
||||
|
||||
if (action.forceRefetch) {
|
||||
if (action.options.forceRefetch) {
|
||||
console.info(`Force-refetching "${action.uri}"`);
|
||||
fetchLibrary();
|
||||
break;
|
||||
|
||||
@ -665,7 +665,7 @@ const MopidyMiddleware = (function () {
|
||||
break;
|
||||
}
|
||||
store.dispatch(
|
||||
coreActions.loadPlaylist(
|
||||
coreActions.loadItem(
|
||||
action.uri,
|
||||
false,
|
||||
{
|
||||
@ -690,7 +690,7 @@ const MopidyMiddleware = (function () {
|
||||
break;
|
||||
}
|
||||
store.dispatch(
|
||||
coreActions.loadPlaylist(
|
||||
coreActions.loadItem(
|
||||
action.uri,
|
||||
false,
|
||||
{
|
||||
|
||||
@ -1035,7 +1035,7 @@ export function getGenres() {
|
||||
* @param uri string
|
||||
* @param full boolean (whether we want a full artist object)
|
||||
* */
|
||||
export function getArtist(uri, full = false, forceRefetch = false) {
|
||||
export function getArtist(uri, { full, forceRefetch }) {
|
||||
return (dispatch, getState) => {
|
||||
const endpoint = `artists/${getFromUri('artistid', uri)}${forceRefetch ? `?refetch=${Date.now()}` : ''}`;
|
||||
request(dispatch, getState, endpoint, 'GET', false, true)
|
||||
@ -1203,7 +1203,7 @@ export function getUserPlaylists(uri) {
|
||||
*
|
||||
* @oaram uri string
|
||||
* */
|
||||
export function getAlbum(uri, forceRefetch) {
|
||||
export function getAlbum(uri, { full, forceRefetch }) {
|
||||
return (dispatch, getState) => {
|
||||
const endpoint = `albums/${getFromUri('albumid', uri)}${forceRefetch ? `?refetch=${Date.now()}` : ''}`;
|
||||
request(dispatch, getState, endpoint)
|
||||
@ -1211,9 +1211,9 @@ export function getAlbum(uri, forceRefetch) {
|
||||
(response) => {
|
||||
dispatch(coreActions.itemLoaded({
|
||||
...formatAlbum(response),
|
||||
tracks: formatTracks(response.tracks.items),
|
||||
}));
|
||||
|
||||
if (full) {
|
||||
let tracks = formatTracks(response.tracks.items);
|
||||
const fetchTracks = (endpoint) => request(dispatch, getState, endpoint)
|
||||
.then((response) => {
|
||||
@ -1231,6 +1231,7 @@ export function getAlbum(uri, forceRefetch) {
|
||||
if (response.tracks.next) {
|
||||
fetchTracks(response.tracks.next);
|
||||
}
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
dispatch(coreActions.handleException(
|
||||
@ -1349,7 +1350,7 @@ export function savePlaylist(uri, name, description, is_public, is_collaborative
|
||||
};
|
||||
}
|
||||
|
||||
export function getPlaylist(uri, forceRefetch = false, callbackAction = null) {
|
||||
export function getPlaylist(uri, { full, forceRefetch, callbackAction }) {
|
||||
return (dispatch, getState) => {
|
||||
const endpoint = `playlists/${getFromUri('playlistid', uri)}?market=${getState().spotify.country}${forceRefetch ? `&refetch=${Date.now()}` : ''}`;
|
||||
request(dispatch, getState, endpoint)
|
||||
@ -1369,10 +1370,10 @@ export function getPlaylist(uri, forceRefetch = false, callbackAction = null) {
|
||||
dispatch(coreActions.itemLoaded({
|
||||
...formatPlaylist(response),
|
||||
can_edit: (getState().spotify.me && getState().spotify.me.id === response.owner.id),
|
||||
tracks,
|
||||
description,
|
||||
}));
|
||||
|
||||
if (full) {
|
||||
const fetchTracks = (endpoint) => request(dispatch, getState, endpoint)
|
||||
.then((response) => {
|
||||
tracks = [...tracks, ...formatTracks(response.items)];
|
||||
@ -1412,6 +1413,7 @@ export function getPlaylist(uri, forceRefetch = false, callbackAction = null) {
|
||||
if (response.tracks.next) {
|
||||
fetchTracks(response.tracks.next);
|
||||
}
|
||||
};
|
||||
},
|
||||
(error) => {
|
||||
dispatch(coreActions.handleException(
|
||||
@ -1722,7 +1724,11 @@ export function getLibraryPlaylists(forceRefetch) {
|
||||
const fetchLibraryPlaylists = (endpoint) => request(dispatch, getState, endpoint)
|
||||
.then((response) => {
|
||||
const items = response.items.map(
|
||||
(item) => ({ ...item, in_library: true }),
|
||||
(item) => ({
|
||||
...item,
|
||||
in_library: true,
|
||||
can_edit: (getState().spotify.me && item.owner.id === getState().spotify.me.id),
|
||||
}),
|
||||
);
|
||||
libraryItems = [...libraryItems, ...formatPlaylists(items)];
|
||||
if (response.next) {
|
||||
|
||||
@ -25,7 +25,6 @@ import {
|
||||
isLoading,
|
||||
sourceIcon,
|
||||
} from '../util/helpers';
|
||||
import { collate } from '../util/format';
|
||||
import Button from '../components/Button';
|
||||
|
||||
export class Album extends React.Component {
|
||||
@ -34,7 +33,7 @@ export class Album extends React.Component {
|
||||
uri,
|
||||
album,
|
||||
coreActions: {
|
||||
loadAlbum,
|
||||
loadItem,
|
||||
},
|
||||
lastfmActions: {
|
||||
getAlbum,
|
||||
@ -42,7 +41,7 @@ export class Album extends React.Component {
|
||||
} = this.props;
|
||||
|
||||
this.setWindowTitle();
|
||||
loadAlbum(uri);
|
||||
loadItem(uri, { full: true });
|
||||
|
||||
if (album) {
|
||||
if (album.artists && album.wiki === undefined) {
|
||||
@ -72,7 +71,7 @@ export class Album extends React.Component {
|
||||
uri,
|
||||
album,
|
||||
coreActions: {
|
||||
loadAlbum,
|
||||
loadItem,
|
||||
},
|
||||
lastfmActions: {
|
||||
getAlbum,
|
||||
@ -80,7 +79,7 @@ export class Album extends React.Component {
|
||||
} = this.props;
|
||||
|
||||
if (uri !== prevUri) {
|
||||
loadAlbum(uri);
|
||||
loadItem(uri, { full: true });
|
||||
}
|
||||
|
||||
// We have just received our full album or our album artists
|
||||
|
||||
@ -36,7 +36,7 @@ import { trackEvent } from '../components/Trackable';
|
||||
class Artist extends React.Component {
|
||||
componentDidMount() {
|
||||
this.setWindowTitle();
|
||||
this.props.coreActions.loadArtist(this.props.uri);
|
||||
this.props.coreActions.loadItem(this.props.uri, { full: true });
|
||||
}
|
||||
|
||||
componentDidUpdate = ({
|
||||
@ -47,12 +47,12 @@ class Artist extends React.Component {
|
||||
uri,
|
||||
artist,
|
||||
coreActions: {
|
||||
loadArtist,
|
||||
loadItem,
|
||||
},
|
||||
} = this.props;
|
||||
|
||||
if (uri !== prevUri) {
|
||||
loadArtist(uri);
|
||||
loadItem(uri, { full: true });
|
||||
}
|
||||
|
||||
if (!prevArtist && artist) this.setWindowTitle(artist);
|
||||
|
||||
@ -26,7 +26,6 @@ import {
|
||||
sourceIcon,
|
||||
decodeMopidyUri,
|
||||
} from '../util/helpers';
|
||||
import { collate } from '../util/format';
|
||||
import { i18n, I18n } from '../locale';
|
||||
|
||||
class Playlist extends React.Component {
|
||||
@ -46,7 +45,7 @@ class Playlist extends React.Component {
|
||||
componentDidMount() {
|
||||
const { coreActions: { loadItem }, uri } = this.props;
|
||||
this.setWindowTitle();
|
||||
loadItem(uri);
|
||||
loadItem(uri, { full: true });
|
||||
}
|
||||
|
||||
componentDidUpdate = ({
|
||||
@ -69,7 +68,7 @@ class Playlist extends React.Component {
|
||||
}
|
||||
|
||||
if (uri !== prevUri) {
|
||||
loadItem(uri);
|
||||
loadItem(uri, { full: true });
|
||||
}
|
||||
|
||||
if (!prevPlaylist && playlist) this.setWindowTitle(playlist);
|
||||
@ -330,7 +329,7 @@ class Playlist extends React.Component {
|
||||
</li>
|
||||
)}
|
||||
<li>
|
||||
<I18n path="specs.tracks" count={playlist.tracks_total || 0} />
|
||||
<I18n path="specs.tracks" count={playlist.tracks ? playlist.tracks.length : 0} />
|
||||
</li>
|
||||
{!slim_mode && playlist.tracks && playlist.tracks_total > 0 && (
|
||||
<li><Dater type="total-time" data={playlist.tracks} /></li>
|
||||
|
||||
@ -34,12 +34,14 @@ class Track extends React.Component {
|
||||
const {
|
||||
uri,
|
||||
track,
|
||||
coreActions: { loadTrack },
|
||||
coreActions: {
|
||||
loadItem,
|
||||
},
|
||||
genius_authorized,
|
||||
geniusActions: { findTrackLyrics },
|
||||
} = this.props;
|
||||
|
||||
loadTrack(uri);
|
||||
loadItem(uri);
|
||||
|
||||
if (track) {
|
||||
this.setWindowTitle(track);
|
||||
@ -60,7 +62,7 @@ class Track extends React.Component {
|
||||
genius_authorized,
|
||||
lastfm_authorized,
|
||||
coreActions: {
|
||||
loadTrack,
|
||||
loadItem,
|
||||
},
|
||||
geniusActions: {
|
||||
findTrackLyrics,
|
||||
@ -71,7 +73,7 @@ class Track extends React.Component {
|
||||
} = this.props;
|
||||
|
||||
if (prevUri !== uri) {
|
||||
loadTrack(uri);
|
||||
loadItem(uri);
|
||||
|
||||
if (genius_authorized && track.artists) {
|
||||
findTrackLyrics(track);
|
||||
|
||||
@ -101,7 +101,7 @@ class LibraryArtists extends React.Component {
|
||||
|
||||
if (source !== 'local' && source !== 'all') return;
|
||||
|
||||
loadLibrary('mopidy:library:artists', forceRefetch);
|
||||
loadLibrary('mopidy:library:artists', { forceRefetch });
|
||||
};
|
||||
|
||||
getGoogleLibrary = (forceRefetch = false) => {
|
||||
@ -116,7 +116,7 @@ class LibraryArtists extends React.Component {
|
||||
if (!google_available) return;
|
||||
if (source !== 'google' && source !== 'all') return;
|
||||
|
||||
loadLibrary('google:library:artists', forceRefetch);
|
||||
loadLibrary('google:library:artists', { forceRefetch });
|
||||
};
|
||||
|
||||
getSpotifyLibrary = (forceRefetch = false) => {
|
||||
@ -131,7 +131,7 @@ class LibraryArtists extends React.Component {
|
||||
if (!spotify_available) return;
|
||||
if (source !== 'spotify' && source !== 'all') return;
|
||||
|
||||
loadLibrary('spotify:library:artists', forceRefetch);
|
||||
loadLibrary('spotify:library:artists', { forceRefetch });
|
||||
};
|
||||
|
||||
loadMore = () => {
|
||||
|
||||
@ -70,7 +70,7 @@ class LibraryPlaylists extends React.Component {
|
||||
|
||||
if (source !== 'local' && source !== 'all') return;
|
||||
|
||||
loadLibrary('mopidy:library:playlists', forceRefetch);
|
||||
loadLibrary('mopidy:library:playlists', { forceRefetch });
|
||||
};
|
||||
|
||||
getSpotifyLibrary = (forceRefetch = false) => {
|
||||
@ -85,7 +85,7 @@ class LibraryPlaylists extends React.Component {
|
||||
if (!spotify_available) return;
|
||||
if (source !== 'spotify' && source !== 'all') return;
|
||||
|
||||
loadLibrary('spotify:library:playlists', forceRefetch);
|
||||
loadLibrary('spotify:library:playlists', { forceRefetch });
|
||||
};
|
||||
|
||||
componentDidUpdate = ({ source: prevSource }) => {
|
||||
|
||||
Reference in New Issue
Block a user