Skip to content

Commit

Permalink
Fix an error on browser console when Last.fm has no tags for the entity
Browse files Browse the repository at this point in the history
There was an error message shown on the browser console when the
Last.fm info was viewed on the details pane and the data for the viewed
artist/album/track happened to contain not a single `tag` property.
Other than the message, this caused no actual harm.
  • Loading branch information
paulijar committed Jun 18, 2023
1 parent 5af08ba commit 35d79d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion js/app/controllers/sidebar/sidebarcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ angular.module('Music').controller('SidebarController', [
});

$scope.formatLastfmTags = function(tags) {
// Last.fm returns individual JSON object in place of array in case there is just one item
// Last.fm returns individual JSON object in place of array in case there is just one item.
// In case there are none, the `tags` is undefined.
tags = tags || [];
if (!Array.isArray(tags)) {
tags = [tags];
}
Expand All @@ -149,6 +151,8 @@ angular.module('Music').controller('SidebarController', [

$scope.formatLinkList = function(linkArray) {
// Last.fm returns individual JSON object in place of array in case there is just one item
// In case there are none, the `linkArray` is undefined.
linkArray = linkArray || [];
if (!Array.isArray(linkArray)) {
linkArray = [linkArray];
}
Expand Down

0 comments on commit 35d79d5

Please sign in to comment.