mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-23 04:29:21 +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 {String} userID User on which to make request (current to get connected user)
|
||||||
* @param {function} afterGetUserInfos What to do once user informations are available
|
* @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){
|
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
|
//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
|
afterGetUserInfos(this.usersInfos[userID]); //Then return these informations now
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//Else we have to perform an API request
|
//Else we have to perform an API request
|
||||||
if(userID == "current" || userID == ComunicWeb.user.userLogin.__userID){
|
var apiURI = "user/getInfos";
|
||||||
var apiURI = "user/getCurrentUserInfos";
|
var params = {
|
||||||
var params = {};
|
userID: userID
|
||||||
}
|
};
|
||||||
else{
|
|
||||||
ComunicWeb.debug.logMessage("ERROR : getUserInfos not implemented for other user than the current one !");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Specify what to do next
|
//Specify what to do next
|
||||||
var onceGetUserInfos = function(result){
|
var onceGetUserInfos = function(result){
|
||||||
if(result.error){
|
if(result.error){
|
||||||
ComunicWeb.debug.logMessage("ERROR : couldn't get infos about user ID : "+userID+" !");
|
ComunicWeb.debug.logMessage("ERROR : couldn't get infos about user ID : "+userID+" !");
|
||||||
|
|
||||||
|
//Returns the error to the next function
|
||||||
|
afterGetUserInfos(result);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
//Save result
|
||||||
|
ComunicWeb.user.userInfos.usersInfos[""+userID] = result[0];
|
||||||
|
|
||||||
//Save result
|
//Return result
|
||||||
ComunicWeb.user.userInfos.usersInfos[""+userID] = result[0];
|
afterGetUserInfos(result[0]);
|
||||||
|
}
|
||||||
//Return result
|
|
||||||
afterGetUserInfos(result[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Perform request
|
//Perform request
|
||||||
|
Loading…
Reference in New Issue
Block a user