Can update following state

This commit is contained in:
Pierre
2017-12-23 17:46:55 +01:00
parent ac86fbcb25
commit a49e068637
3 changed files with 84 additions and 0 deletions

View File

@ -160,6 +160,49 @@ ComunicWeb.pages.userPage.friendshipStatus = {
}
//Offer user to follow other user
else {
//Setup button
var followButton = createElem2({
appendTo: target,
type: "button",
class: "btn btn-primary btn-block",
});
if(response.following){
followButton.innerHTML = "Following";
followButton.setAttribute("data-following", "true");
}
else {
followButton.innerHTML = "Follow";
followButton.setAttribute("data-following", "false");
}
//Make the follow button live
followButton.onclick = function(){
//Lock button
this.disabled = true;
//Check if the user has to be followed or not (reverse current state)
var follow = this.getAttribute("data-following") == "false";
ComunicWeb.components.friends.list.setFollowing(userID, follow, function(response){
//Check for errors
if(response.error){
ComunicWeb.common.notificationSystem.showNotification("An error occured while trying to update following status !");
}
//Reload this component
ComunicWeb.pages.userPage.friendshipStatus.display(userID, target);
});
}
}
});
}

View File

@ -59,5 +59,19 @@ ComunicWeb.pages.userPage.profileInfos = {
class: "profile-username text-center",
innerHTML: infos.firstName + " " + infos.lastName
});
//Add user status informations (if required)
if(signed_in()){
if(userID() != infos.userID){
var userStatus = createElem2({
appendTo: boxBody,
type: "div",
innerHTML: "Loading...",
});
userStatus.style.textAlign = "center";
ComunicWeb.pages.userPage.friendshipStatus.display(infos.userID, userStatus);
}
}
}
};