mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-12-27 03:08:51 +00:00
Progress on friend bar
This commit is contained in:
parent
7eb6bf383c
commit
174ad6779a
@ -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 = {
|
||||
|
||||
};
|
@ -68,7 +68,8 @@ $config['JSfiles'] = array(
|
||||
"%PATH_ASSETS%js/components/menuBar/common.js",
|
||||
"%PATH_ASSETS%js/components/menuBar/notAuthenticated.js",
|
||||
"%PATH_ASSETS%js/components/menuBar/authenticated.js",
|
||||
"%PATH_ASSETS%js/components/friendsList/friendsList.js",
|
||||
"%PATH_ASSETS%js/components/friends/friendsList.js",
|
||||
"%PATH_ASSETS%js/components/friends/friendsBar.js",
|
||||
|
||||
//User scripts
|
||||
"%PATH_ASSETS%js/user/loginTokens.js",
|
||||
|
Loading…
Reference in New Issue
Block a user