Lazy-loading album tracks, fixes #484
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
|
||||
import * as helpers from '../../helpers';
|
||||
import * as helpers from '../../helpers';
|
||||
|
||||
const spotifyActions = require('../../services/spotify/actions');
|
||||
const mopidyActions = require('../../services/mopidy/actions');
|
||||
@ -221,13 +221,14 @@ export function userPlaylistsLoaded(uri, playlists, more = null, total = null) {
|
||||
};
|
||||
}
|
||||
|
||||
export function loadedMore(parent_type, parent_key, records_type, records_data) {
|
||||
export function loadedMore(parent_type, parent_key, records_type, records_data, extra_data = {}) {
|
||||
return {
|
||||
type: 'LOADED_MORE',
|
||||
parent_type,
|
||||
parent_key,
|
||||
records_type,
|
||||
records_data,
|
||||
extra_data,
|
||||
};
|
||||
}
|
||||
|
||||
@ -247,7 +248,7 @@ export function removeFromIndex(index_name, key, new_key = null) {
|
||||
|
||||
export function reorderPlaylistTracks(uri, indexes, insert_before, snapshot_id = false) {
|
||||
const range = helpers.createRange(indexes);
|
||||
switch (helpers.uriSource(uri)) {
|
||||
switch (helpers.uriSource(uri)) {
|
||||
case 'spotify':
|
||||
return {
|
||||
type: 'SPOTIFY_REORDER_PLAYLIST_TRACKS',
|
||||
@ -270,7 +271,7 @@ export function reorderPlaylistTracks(uri, indexes, insert_before, snapshot_id =
|
||||
}
|
||||
|
||||
export function savePlaylist(uri, name, description = '', is_public = false, is_collaborative = false, image = null) {
|
||||
switch (helpers.uriSource(uri)) {
|
||||
switch (helpers.uriSource(uri)) {
|
||||
case 'spotify':
|
||||
return {
|
||||
type: 'SPOTIFY_SAVE_PLAYLIST',
|
||||
@ -293,7 +294,7 @@ export function savePlaylist(uri, name, description = '', is_public = false, is_
|
||||
}
|
||||
|
||||
export function createPlaylist(scheme, name, description = '', is_public = false, is_collaborative = false) {
|
||||
switch (scheme) {
|
||||
switch (scheme) {
|
||||
case 'spotify':
|
||||
if (description == '') {
|
||||
description = null;
|
||||
@ -307,7 +308,7 @@ export function createPlaylist(scheme, name, description = '', is_public = false
|
||||
}
|
||||
|
||||
export function deletePlaylist(uri) {
|
||||
switch (helpers.uriSource(uri)) {
|
||||
switch (helpers.uriSource(uri)) {
|
||||
case 'spotify':
|
||||
return spotifyActions.following(uri, 'DELETE');
|
||||
|
||||
@ -318,7 +319,7 @@ export function deletePlaylist(uri) {
|
||||
}
|
||||
|
||||
export function removeTracksFromPlaylist(uri, tracks_indexes) {
|
||||
switch (helpers.uriSource(uri)) {
|
||||
switch (helpers.uriSource(uri)) {
|
||||
case 'spotify':
|
||||
return {
|
||||
type: 'SPOTIFY_REMOVE_PLAYLIST_TRACKS',
|
||||
@ -336,7 +337,7 @@ export function removeTracksFromPlaylist(uri, tracks_indexes) {
|
||||
}
|
||||
|
||||
export function addTracksToPlaylist(uri, tracks_uris) {
|
||||
switch (helpers.uriSource(uri)) {
|
||||
switch (helpers.uriSource(uri)) {
|
||||
case 'spotify':
|
||||
return {
|
||||
type: 'SPOTIFY_ADD_PLAYLIST_TRACKS',
|
||||
|
||||
@ -760,6 +760,11 @@ const CoreMiddleware = (function () {
|
||||
var records_index = {};
|
||||
var records_uris = helpers.arrayOf('uri', records);
|
||||
|
||||
// Merge any extra data (eg more_track's albums)
|
||||
if (action.extra_data) {
|
||||
records = records.map(record => ({ ...record, ...action.extra_data }));
|
||||
}
|
||||
|
||||
// If we're a list of playlists, we need to manually filter Spotify's new URI structure
|
||||
// Really poor form because they haven't updated it everywhere, yet
|
||||
if (action.records_type == 'playlist') {
|
||||
|
||||
Reference in New Issue
Block a user