profiles: friend and block through profile page :))
This commit is contained in:
@ -18,7 +18,7 @@ class MyProfile extends Profile
|
||||
/**
|
||||
* @type {[Profile]}
|
||||
*/
|
||||
this.friends = [];
|
||||
this.friendList = [];
|
||||
/**
|
||||
* @type {[Profile]}
|
||||
*/
|
||||
@ -46,7 +46,7 @@ class MyProfile extends Profile
|
||||
async getFriends() {
|
||||
const response = await this.client._get('/api/profiles/friends');
|
||||
const data = await response.json();
|
||||
data.forEach(profileData => this.friends.push(new Profile(this.client, profileData.username, profileData.user_id, profileData.avatar)));
|
||||
data.forEach(profileData => this.friendList.push(new Profile(this.client, profileData.username, profileData.user_id, profileData.avatar)));
|
||||
}
|
||||
async getIncomingFriendRequests() {
|
||||
const response = await this.client._get('/api/profiles/incoming_friend_requests');
|
||||
@ -62,6 +62,52 @@ class MyProfile extends Profile
|
||||
new Profile(this.client, profileData.username, profileData.user_id, profileData.avatar)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Profile} profile
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
_isFriend(profile) {
|
||||
for (const user of this.friendList) {
|
||||
if (user.id === profile.id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @param {Profile} profile
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
_isBlocked(profile) {
|
||||
for (const user of this.blockedUsers) {
|
||||
if (user.id === profile.id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @param {Profile} profile
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
_hasIncomingRequestFrom(profile) {
|
||||
for (const user of this.incomingFriendRequests) {
|
||||
if (user.id === profile.id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @param {Profile} profile
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
_hasOutgoingRequestTo(profile) {
|
||||
for (const user of this.outgoingFriendRequests) {
|
||||
if (user.id === profile.id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {File} selectedFile
|
||||
|
Reference in New Issue
Block a user