mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-06-19 12:25:16 +00:00
Can update following state
This commit is contained in:
@ -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);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user