Intermittent Issue With Tracks Snapshot For Current User Top List
I have a problem when executing this code: require(['$api/models','$api/library#Library'], function(models,Library) { // THIS ONLY HAPPEN FOR TOP LIST var uri=Library.forCurrentUs
Solution 1:
Library's toplist property is already a playlist, so you don't need to create a new Playlist object from its URI. This snippet does the same as yours, but loads the toplist property and uses it to get the tracks directly instead of creating a new playlist.
require(['$api/models','$api/library#Library'], function(models,Library) {
var library = Library.forCurrentUser();
library.load("toplist").done(function() {
var toplist = library.toplist;
toplist.load('tracks').done(function() {
console.log("loaded 1");
toplist.tracks.snapshot().done(function(snapshot) {
console.log("snapshot length 1 " + snapshot.length);
snapshot.loadAll('name')
.done(function(snap_tracks) { console.log("loaded tracks length 1 " + snap_tracks.length); })
.fail(function() { console.log("loadAll failed"); });
}).fail(function() { console.log("snapshot failed"); });
}).fail(function() { console.log("playlist load tracks failed"); });
}).fail(function() {
console.log("Could not load toplist.");
});
});
i did try the snippet you provided, and similarly to Thomas I couldn't find anything wrong with it. Hope this helps though.
Solution 2:
Either it's a localized issue (I can't repro), or due to the asynchronous nature of the functions, you can't make the same call twice on the same playlist.
I've tried your code 3 times (on Windows v0.9.6) without seeing the behavior you're seeing.
Renaming playlist1,2,3 didn't change the behavior for me, works both ways.
Post a Comment for "Intermittent Issue With Tracks Snapshot For Current User Top List"