profiles: friend requests

This commit is contained in:
AdrienLSH
2024-04-18 11:40:42 +02:00
parent 5a2da91d6e
commit 9f61cda73f
4 changed files with 73 additions and 8 deletions

View File

@ -19,12 +19,22 @@ class MyProfile extends Profile
* @type {[Profile]}
*/
this.friends = [];
/**
* @type {[Profile]}
*/
this.incomingFriendRequests = [];
/**
* @type {[Profile]}
*/
this.outgoingFriendRequests = [];
}
async init() {
await super.init();
await this.getBlockedUsers();
await this.getFriends();
await this.getIncomingFriendRequests()
await this.getOutgoingFriendRequests()
}
async getBlockedUsers() {
@ -38,6 +48,20 @@ class MyProfile extends Profile
const data = await response.json();
data.forEach(profileData => this.friends.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');
const data = await response.json();
data.forEach(profileData => this.incomingFriendRequests.push(
new Profile(this.client, profileData.username, profileData.user_id, profileData.avatar)
));
}
async getOutgoingFriendRequests() {
const response = await this.client._get('/api/profiles/outgoing_friend_requests');
const data = await response.json();
data.forEach(profileData => this.outgoingFriendRequests.push(
new Profile(this.client, profileData.username, profileData.user_id, profileData.avatar)
));
}
/**
*
* @param {File} selectedFile