Skip to content

Commit

Permalink
fix: display the friends when the app is deployed
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmc07 committed May 4, 2023
1 parent 87a27fd commit 52764f5
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions webapp/src/components/place/PrivacyComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ interface PrivacyComponentState {
*/
class PrivacyComponent extends Component<PrivacyComponentProps, PrivacyComponentState> {

private loadedFriends: boolean = false;

constructor(props: PrivacyComponentProps) {
super(props);
this.state = {
selectedPrivacy: "public",
selectedFriends: {},
friendsList: new Array<User>(),
friendsSelected: [],
loadedFriends: false,
loadedFriends: true,
friendsButton: false,
prevFriendsButton: false,
};
Expand All @@ -44,30 +42,19 @@ class PrivacyComponent extends Component<PrivacyComponentProps, PrivacyComponent

async componentDidMount() {
// We assign to users the actual list of users
this.getUsers().then(() => {
if (this.state.friendsList.length === 0) {
this.setState(() => ({
loadedFriends: false,
}));
} else {
this.setState(() => ({
loadedFriends: true,
}));
}
}).catch((error) => {
this.setState(() => ({
loadedFriends: true,
await this.getUsers().catch((error) => {
this.setState({
friendsList: []
}));
});
});
}

/**
* It recovers the friends from the current user logged in
* */
private async getUsers() {
let fm = new FriendManager();
this.setState({friendsList: await fm.getFriendsList()});
let friends = await new FriendManager().getFriendsList();
this.setState({friendsList: friends, loadedFriends: true});
}

/**
Expand Down

0 comments on commit 52764f5

Please sign in to comment.