From 6a73e9fb999368c653c32632e3beca0e253eb3ba Mon Sep 17 00:00:00 2001 From: Atanamo Date: Sun, 22 Nov 2015 17:45:50 +0100 Subject: [PATCH] Fix null pointer exception while albums loading See issue #25: The songs array may lacks an entry for an album. This can break up the whole albums view. --- js/app.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/app.js b/js/app.js index 2abe652..dd8d510 100755 --- a/js/app.js +++ b/js/app.js @@ -499,9 +499,13 @@ Audios.prototype.loadAlbums = function(){ divSongsContainer.append(listAlbumSelect); var aSongs=[]; - $.each(songs[album.id],function(ii,songs){ - aSongs[ii] = $this.loadSongsRow(songs, album.name); - }); + if(songs[album.id]){ + $.each(songs[album.id],function(ii,songs){ + aSongs[ii] = $this.loadSongsRow(songs, album.name); + }); + }else{ + console.warn('Could not find songs for album:', album.name, album); + } listAlbumSelect.append(aSongs); var br = $('
').css('clear','both');