VRFS-3105 : Update online presence after updating, and not just on init. Also call show on the appropriate elements, as they could be hidden if an item is being set for the first time.

This commit is contained in:
Steven Miers 2015-05-08 16:44:55 -05:00
parent ca46ffa43b
commit 3314515577
1 changed files with 47 additions and 62 deletions

View File

@ -125,12 +125,13 @@
function beforeShow(data) {
userId = data.id;
feed.setUser(userId);
feed.setUser(userId);
}
function afterShow(data) {
initUser();
resetForm();
renderAllStats();
}
function beforeHide(data) {
@ -159,6 +160,7 @@
user = response;
configureUserType();
renderActive();
renderAllStats();
})
.fail(function (jqXHR) {
if (jqXHR.status >= 500) {
@ -193,8 +195,7 @@
$socialLeft.show();
$typeLabel.text('musician');
$location.text('Location');
}
else {
} else {
$historyLink.hide();
$bandsLink.hide();
$instruments.hide();
@ -212,8 +213,7 @@
$btnAddFriend.hide();
$btnFollowUser.hide();
$btnMessageUser.hide();
}
else {
} else {
configureFriendFollowersControls();
$btnEdit.hide();
@ -264,8 +264,7 @@
function handleFriendChange(evt) {
if (isFriend()) {
removeFriend(evt);
}
else {
} else {
sendFriendRequest(evt);
}
return false;
@ -274,8 +273,7 @@
function handleFollowingChange(evt) {
if (isFollowing()) {
removeFollowing(false, userId);
}
else {
} else {
addFollowing();
}
return false;
@ -320,8 +318,7 @@
function configureFriendButton() {
if (isFriend()) {
$btnAddFriend.text('DISCONNECT');
}
else {
} else {
$btnAddFriend.text('CONNECT');
}
}
@ -366,8 +363,7 @@
if (isFollowing()) {
$btnFollowUser.text('UNFOLLOW');
}
else {
} else {
$btnFollowUser.text('FOLLOW');
}
}
@ -423,12 +419,10 @@
$favoritesContent.hide();
$('.profile-nav a.active').removeClass('active');
$aboutLink.addClass('active');
bindAbout();
$aboutLink.addClass('active');
}
function bindAbout() {
function renderAllStats() {
if (!isCurrentUser()) {
$btnEditBio.hide();
@ -437,12 +431,14 @@
$btnAddInterests.hide();
}
renderNameLocationStats();
renderBio();
renderMusicalExperience();
renderPerformanceSamples();
renderOnlinePresence();
renderInterests();
if (user && $userName) {
renderNameLocationStats();
renderBio();
renderMusicalExperience();
renderPerformanceSamples();
renderOnlinePresence();
renderInterests();
}
}
function renderNameLocationStats() {
@ -470,8 +466,7 @@
text = user.recording_count > 1 || user.recording_count === 0 ? " Recordings" : " Recording";
$recordingStats.html(user.recording_count + text);
}
else {
} else {
text = " Following";
$followingStats.html(user.following_count + text);
text = user.favorite_count > 1 || user.favorite_count === 0 ? " Favorites" : " Favorite";
@ -483,8 +478,7 @@
$biography.html(user.biography ? user.biography : NOT_SPECIFIED_TEXT);
if (isCurrentUser() && !user.biography) {
$btnEditBio.show();
}
else {
} else {
$btnEditBio.hide();
}
}
@ -539,8 +533,7 @@
if (isCurrentUser()) {
$btnAddRecordings.show();
}
}
else {
} else {
$btnAddRecordings.hide();
$noSamples.hide();
@ -588,12 +581,11 @@
if (isCurrentUser()) {
$btnAddSites.show();
}
else {
} else {
$btnAddSites.hide();
}
}
else {
} else {
console.log("Showing onnline presences....")
$btnAddSites.hide();
$noOnlinePresence.hide();
@ -602,58 +594,59 @@
}
var soundCloudPresences = profileUtils.soundCloudPresences(onlinePresences);
console.log("Showing soundkcoud presences....", soundCloudPresences, $soundCloudPresence)
if (soundCloudPresences && soundCloudPresences.length > 0) {
$soundCloudPresence.find('a').attr('href', 'http://www.soundcloud.com/' + soundCloudPresences[0].username);
}
else {
$soundCloudPresence.show();
} else {
$soundCloudPresence.hide();
}
var reverbNationPresences = profileUtils.reverbNationPresences(onlinePresences);
if (reverbNationPresences && reverbNationPresences.length > 0) {
$reverbNationPresence.find('a').attr('href', 'http://www.reverbnation.com/' + reverbNationPresences[0].username);
}
else {
$reverbNationPresence.show();
} else {
$reverbNationPresence.hide();
}
var bandCampPresences = profileUtils.bandCampPresences(onlinePresences);
if (bandCampPresences && bandCampPresences.length > 0) {
$bandCampPresence.find('a').attr('href', 'http://' + bandCampPresences[0].username + '.bandcamp.com/');
}
else {
$bandCampPresence.show();
} else {
$bandCampPresence.hide();
}
var fandalismPresences = profileUtils.fandalismPresences(onlinePresences);
if (fandalismPresences && fandalismPresences.length > 0) {
$fandalismPresence.find('a').attr('href', 'http://www.fandalism.com/' + fandalismPresences[0].username);
}
else {
$fandalismPresence.show();
} else {
$fandalismPresence.hide();
}
var youTubePresences = profileUtils.youTubePresences(onlinePresences);
if (youTubePresences && youTubePresences.length > 0) {
$youTubePresence.find('a').attr('href', 'http://www.youtube.com/' + youTubePresences[0].username);
}
else {
$youTubePresence.show();
} else {
$youTubePresence.hide();
}
var facebookPresences = profileUtils.facebookPresences(onlinePresences);
if (facebookPresences && facebookPresences.length > 0) {
$facebookPresence.find('a').attr('href', 'http://www.facebook.com/' + facebookPresences[0].username);
}
else {
$facebookPresence.show();
} else {
$facebookPresence.hide();
}
var twitterPresences = profileUtils.twitterPresences(onlinePresences);
if (twitterPresences && twitterPresences.length > 0) {
$twitterPresence.find('a').attr('href', 'http://www.twitter.com/' + twitterPresences[0].username);
}
else {
$twitterPresence.show();
} else {
$twitterPresence.hide();
}
}
@ -673,9 +666,7 @@
if (isCurrentUser()) {
$btnAddInterests.show();
}
}
else {
} else {
$btnAddInterests.hide();
$noInterests.hide();
@ -691,8 +682,7 @@
var dailyRate = user.paid_sessions_daily_rate;
$paidGigDetails.find("ul li:nth-child(3)").html('Day rate = ' + (dailyRate ? dailyRate : NOT_SPECIFIED_TEXT));
}
else {
} else {
$paidGigSection.hide();
}
@ -702,8 +692,7 @@
var genreList = profileUtils.freeSessionGenreList(user.genres);
$freeGigDetails.find("ul li:nth-child(1)").html('Genre(s): ' + (genreList.length > 0 ? genreList : NOT_SPECIFIED_TEXT));
}
else {
} else {
$freeGigSection.hide();
}
@ -716,8 +705,7 @@
var purpose = user.cowriting_purpose;
$cowritingDetails.find("ul li:nth-child(2)").html('Purpose: ' + (purpose ? profileUtils.cowritingPurposeMap[purpose] : NOT_SPECIFIED_TEXT));
}
else {
} else {
$cowritingSection.hide();
}
@ -734,8 +722,7 @@
var canTour = user.traditional_band_touring;
var canTourResponse = canTour ? "Yes" : (canTour === false ? "No" : NOT_SPECIFIED_TEXT);
$traditionalBandDetails.find("ul li:nth-child(3)").html('Touring: ' + canTourResponse);
}
else {
} else {
$traditionalBandSection.hide();
}
@ -748,8 +735,7 @@
var commitment = user.virtual_band_commitment;
$virtualBandDetails.find("ul li:nth-child(2)").html('Commitment: ' + (commitment ? profileUtils.bandCommitmentMap[commitment] : NOT_SPECIFIED_TEXT));
}
else {
} else {
$virtualBandSection.hide();
}
}
@ -1032,8 +1018,7 @@
evt.stopPropagation();
return false;
});
}
else {
} else {
$btnFollowBand.text('FOLLOW');
$btnFollowBand.click(addBandFollowing);
}