mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 12:14:12 +00:00 
			
		
		
		
	Progress on friend bar
This commit is contained in:
		@@ -187,7 +187,7 @@ ComunicWeb.common.page = {
 | 
			
		||||
            //We load specific components for logged in users
 | 
			
		||||
            if(ComunicWeb.user.userLogin.getUserLoginState()){
 | 
			
		||||
                //We load frieds list (if user is logged in)
 | 
			
		||||
                ComunicWeb.components.friendsList.display();
 | 
			
		||||
                ComunicWeb.components.friends.bar.display();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -65,27 +65,36 @@ ComunicWeb.components.friends.bar = {
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Refresh a friend list
 | 
			
		||||
	 * Refresh the listbar
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param {HTMLElement} listFriendsElem The element that contains the list of friens
 | 
			
		||||
	 * @return {Boolean} True for a success
 | 
			
		||||
	 */
 | 
			
		||||
	refresh: function(listFriendsElem){
 | 
			
		||||
		//First, perform an API request
 | 
			
		||||
		var apiURI = "friends/getList";
 | 
			
		||||
		var params = {};
 | 
			
		||||
 | 
			
		||||
		//Perform request
 | 
			
		||||
		ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, function(result){
 | 
			
		||||
			
 | 
			
		||||
		//Refresh it
 | 
			
		||||
		ComunicWeb.components.friends.list.refresh(function(list){
 | 
			
		||||
			//Check for error
 | 
			
		||||
			if(result.error){
 | 
			
		||||
				ComunicWeb.debug.logMessage("Couldn't get a new version of friends list !");
 | 
			
		||||
			if(!list){
 | 
			
		||||
				//Log information
 | 
			
		||||
				ComunicWeb.debug.logMessage("ERROR : Can't refresh menubar without the latest list !");
 | 
			
		||||
 | 
			
		||||
				//Error
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			//Log information
 | 
			
		||||
			ComunicWeb.debug.logMessage("Got a new version of friends list !");
 | 
			
		||||
			//Get users list to get information about them
 | 
			
		||||
			usersID = {};
 | 
			
		||||
			for(i in list){
 | 
			
		||||
				//Extract user id
 | 
			
		||||
				var processID = list[i].ID_friend;
 | 
			
		||||
 | 
			
		||||
				usersID["user_"+processID] = processID;
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			//Get users ID informations
 | 
			
		||||
			ComunicWeb.user.userInfos.getMultipleUsersInfos(usersID, function(usersInfo){
 | 
			
		||||
				console.log(usersInfo);
 | 
			
		||||
			});
 | 
			
		||||
		});
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										65
									
								
								assets/js/components/friends/friendsList.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								assets/js/components/friends/friendsList.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,65 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Friends list caching system
 | 
			
		||||
 * 
 | 
			
		||||
 * @author Pierre HUBERT
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
ComunicWeb.components.friends.list = {
 | 
			
		||||
	/**
 | 
			
		||||
	 * Last list cached
 | 
			
		||||
	 */
 | 
			
		||||
	__list: {},
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Refresh the list
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param {Function} afterRefreshList What to do next
 | 
			
		||||
	 * @return {Boolean} True for a success
 | 
			
		||||
	 */
 | 
			
		||||
	refresh: function(afterRefreshList){
 | 
			
		||||
 | 
			
		||||
		//First, perform an API request
 | 
			
		||||
		var apiURI = "friends/getList";
 | 
			
		||||
		var params = {};
 | 
			
		||||
 | 
			
		||||
		//Perform request
 | 
			
		||||
		ComunicWeb.common.api.makeAPIrequest(apiURI, params, true, function(result){
 | 
			
		||||
			
 | 
			
		||||
			//Check for error
 | 
			
		||||
			if(result.error){
 | 
			
		||||
				ComunicWeb.debug.logMessage("Couldn't get a new version of friends list !");
 | 
			
		||||
 | 
			
		||||
				//Perform next action...
 | 
			
		||||
				afterRefreshList(false);
 | 
			
		||||
 | 
			
		||||
				//Error
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			//Log information
 | 
			
		||||
			ComunicWeb.debug.logMessage("Got a new version of friends list !");
 | 
			
		||||
 | 
			
		||||
			//Cache the new list
 | 
			
		||||
			ComunicWeb.components.friends.list.__list = result;
 | 
			
		||||
 | 
			
		||||
			//Perform next action
 | 
			
		||||
			afterRefreshList(result);
 | 
			
		||||
 | 
			
		||||
			//Success
 | 
			
		||||
			return true;
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		//It is a success
 | 
			
		||||
		return true;
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get the list
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @return {Object} The list
 | 
			
		||||
	 */
 | 
			
		||||
	get: function(){
 | 
			
		||||
		//Return the list
 | 
			
		||||
		return this.__list;
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
@@ -1,9 +0,0 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Friends list caching system
 | 
			
		||||
 * 
 | 
			
		||||
 * @author Pierre HUBERT
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
ComunicWeb.components.friends.list = {
 | 
			
		||||
	
 | 
			
		||||
};
 | 
			
		||||
		Reference in New Issue
	
	Block a user