mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-12-24 01:48:50 +00:00
Search results are correctly shown
This commit is contained in:
parent
32cf8601f7
commit
736f740d05
@ -16,35 +16,43 @@ ComunicWeb.user.userInfos = {
|
||||
*
|
||||
* @param {String} userID User on which to make request (current to get connected user)
|
||||
* @param {function} afterGetUserInfos What to do once user informations are available
|
||||
* @return {Boolean} False if it fails
|
||||
* @return {Boolean} True for a success
|
||||
*/
|
||||
getUserInfos: function(userID, afterGetUserInfos){
|
||||
|
||||
//If requested user is the current user, replace "current" with userID
|
||||
if(userID === "current")
|
||||
userID = ComunicWeb.user.userLogin.__userID;
|
||||
|
||||
//First, check if informations are already available in the cache
|
||||
if(this.usersInfos[userID])
|
||||
if(this.usersInfos[userID]){
|
||||
afterGetUserInfos(this.usersInfos[userID]); //Then return these informations now
|
||||
return true;
|
||||
}
|
||||
|
||||
//Else we have to perform an API request
|
||||
if(userID == "current" || userID == ComunicWeb.user.userLogin.__userID){
|
||||
var apiURI = "user/getCurrentUserInfos";
|
||||
var params = {};
|
||||
}
|
||||
else{
|
||||
ComunicWeb.debug.logMessage("ERROR : getUserInfos not implemented for other user than the current one !");
|
||||
return false;
|
||||
}
|
||||
var apiURI = "user/getInfos";
|
||||
var params = {
|
||||
userID: userID
|
||||
};
|
||||
|
||||
//Specify what to do next
|
||||
var onceGetUserInfos = function(result){
|
||||
if(result.error){
|
||||
ComunicWeb.debug.logMessage("ERROR : couldn't get infos about user ID : "+userID+" !");
|
||||
|
||||
//Returns the error to the next function
|
||||
afterGetUserInfos(result);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Save result
|
||||
ComunicWeb.user.userInfos.usersInfos[""+userID] = result[0];
|
||||
else {
|
||||
//Save result
|
||||
ComunicWeb.user.userInfos.usersInfos[""+userID] = result[0];
|
||||
|
||||
//Return result
|
||||
afterGetUserInfos(result[0]);
|
||||
//Return result
|
||||
afterGetUserInfos(result[0]);
|
||||
}
|
||||
}
|
||||
|
||||
//Perform request
|
||||
|
Loading…
Reference in New Issue
Block a user