From fde9c64e118d170121facfd427cc695b92d5f699 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Fri, 14 Mar 2014 00:57:28 -0400 Subject: [PATCH] VRFS-1439 fix display issue in musician profile social tab --- web/app/assets/javascripts/profile.js | 60 ++++++++++++++++----------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/web/app/assets/javascripts/profile.js b/web/app/assets/javascripts/profile.js index 7fe0dffa9..2f76d9809 100644 --- a/web/app/assets/javascripts/profile.js +++ b/web/app/assets/javascripts/profile.js @@ -477,20 +477,25 @@ // FRIENDS rest.getFriends({id: userId}) .done(function (response) { - $.each(response, function (index, val) { - var template = $('#template-profile-social').html(); - var friendHtml = context.JK.fillTemplate(template, { - userId: val.id, - hoverAttributeId: "user-id", - hoverAction: val.musician ? "musician" : "fan", - avatar_url: context.JK.resolveAvatarUrl(val.photo_url), - userName: val.name, - location: val.location, - type: "Friends" - }); + if (response && response.length > 0) { + $.each(response, function (index, val) { + var template = $('#template-profile-social').html(); + var friendHtml = context.JK.fillTemplate(template, { + userId: val.id, + hoverAttributeId: "user-id", + hoverAction: val.musician ? "musician" : "fan", + avatar_url: context.JK.resolveAvatarUrl(val.photo_url), + userName: val.name, + location: val.location, + type: "Friends" + }); - $('#profile-social-friends').append(friendHtml); - }); + $('#profile-social-friends').append(friendHtml); + }); + } + else { + $('#profile-social-friends').html(' '); + } context.JK.bindHoverEvents(); }) .fail(app.ajaxError) @@ -498,19 +503,24 @@ rest.getFollowings({id: userId}) .done(function (response) { - $.each(response, function (index, val) { - var template = $('#template-profile-social').html(); - var followingHtml = context.JK.fillTemplate(template, { - userId: val.id, - hoverAttributeId: val.type === "user" ? "user-id" : "band-id", - hoverAction: val.type === "user" ? (val.musician ? "musician" : "fan") : "band", - avatar_url: context.JK.resolveAvatarUrl(val.photo_url), - userName: val.name, - location: val.location - }); + if (response && response.length > 0) { + $.each(response, function (index, val) { + var template = $('#template-profile-social').html(); + var followingHtml = context.JK.fillTemplate(template, { + userId: val.id, + hoverAttributeId: val.type === "user" ? "user-id" : "band-id", + hoverAction: val.type === "user" ? (val.musician ? "musician" : "fan") : "band", + avatar_url: context.JK.resolveAvatarUrl(val.photo_url), + userName: val.name, + location: val.location + }); - $('#profile-social-followings').append(followingHtml); - }); + $('#profile-social-followings').append(followingHtml); + }); + } + else { + $('#profile-social-followings').html(' '); + } context.JK.bindHoverEvents(); }) .fail(app.ajaxError);