profiles: retrieve friends on login

This commit is contained in:
AdrienLSH 2024-04-09 14:04:15 +02:00
parent 0127a22a46
commit 5c32d205c6

View File

@ -15,11 +15,16 @@ class MyProfile extends Profile
* @type {[Profile]}
*/
this.blockedUsers = [];
/**
* @type {[Profile]}
*/
this.friends = [];
}
async init() {
await super.init();
await this.getBlockedUsers();
await this.getFriends();
}
async getBlockedUsers() {
@ -28,6 +33,11 @@ class MyProfile extends Profile
data.forEach(profileData => this.blockedUsers.push(new Profile(this.client, profileData.username, profileData.user_id, profileData.avatar)));
}
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)));
}
/**
*
* @param {File} selectedFile