Formatting of items in loadMore, opportunity to improve performance with fewer loops
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -98,7 +98,7 @@
|
||||
|
||||
// Release details
|
||||
// These are automatically injected to built HTML
|
||||
var build = "1537312704";
|
||||
var build = "1537343873";
|
||||
var version = "3.25.1";
|
||||
|
||||
// Construct the script tag
|
||||
|
||||
@ -333,6 +333,48 @@ export let formatSimpleObject = function(data){
|
||||
return simple_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format multiple items
|
||||
*
|
||||
* @param tracks Array
|
||||
* @return Array
|
||||
**/
|
||||
export let formatTracks = function(records = []){
|
||||
var formatted = [];
|
||||
for (var record of records){
|
||||
formatted.push(formatTrack(record));
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
export let formatAlbums = function(records = []){
|
||||
var formatted = [];
|
||||
for (var record of records){
|
||||
formatted.push(formatAlbum(record));
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
export let formatArtists = function(records = []){
|
||||
var formatted = [];
|
||||
for (var record of records){
|
||||
formatted.push(formatArtist(record));
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
export let formatPlaylists = function(records = []){
|
||||
var formatted = [];
|
||||
for (var record of records){
|
||||
formatted.push(formatTrack(record));
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
export let formatUsers = function(records = []){
|
||||
var formatted = [];
|
||||
for (var record of records){
|
||||
formatted.push(formatUser(record));
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Format our album objects into a universal format
|
||||
@ -659,24 +701,6 @@ export let formatTrack = function(data){
|
||||
return track;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format multiple tracks
|
||||
*
|
||||
* @param tracks Array
|
||||
* @return Array
|
||||
**/
|
||||
export let formatTracks = function(tracks){
|
||||
if (!tracks || tracks === undefined){
|
||||
return null;
|
||||
}
|
||||
|
||||
var formatted = [];
|
||||
for (var i = 0; i < tracks.length; i++){
|
||||
formatted.push(formatTrack(tracks[i]));
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Collate an object with external references into a fully self-contained object
|
||||
|
||||
@ -759,8 +759,26 @@ const CoreMiddleware = (function(){
|
||||
var records = action.records_data;
|
||||
}
|
||||
|
||||
switch (action.records_type){
|
||||
case 'track':
|
||||
records = helpers.formatTracks(records);
|
||||
break;
|
||||
case 'artist':
|
||||
records = helpers.formatArtists(records);
|
||||
break;
|
||||
case 'album':
|
||||
records = helpers.formatAlbums(records);
|
||||
break;
|
||||
case 'playlist':
|
||||
records = helpers.formatPlaylists(records);
|
||||
break;
|
||||
case 'user':
|
||||
records = helpers.formatUsers(records);
|
||||
break;
|
||||
}
|
||||
|
||||
var records_type_plural = action.records_type+'s';
|
||||
var records_index = Object.assign({});
|
||||
var records_index = {};
|
||||
var records_uris = helpers.arrayOf('uri', records);
|
||||
|
||||
// Append our records_uris array with our new records
|
||||
@ -787,6 +805,9 @@ const CoreMiddleware = (function(){
|
||||
records_action[records_type_plural] = records;
|
||||
store.dispatch(records_action);
|
||||
|
||||
//console.log(parent_action);
|
||||
//console.log(records_action);
|
||||
|
||||
next(action);
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user