diff --git a/srcs/requirements/nestjs/api_back/src/friendship/friendship.service.ts b/srcs/requirements/nestjs/api_back/src/friendship/friendship.service.ts index 2089c023..d0aba0ab 100644 --- a/srcs/requirements/nestjs/api_back/src/friendship/friendship.service.ts +++ b/srcs/requirements/nestjs/api_back/src/friendship/friendship.service.ts @@ -1,9 +1,6 @@ import { HttpException, HttpStatus, Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { User } from 'src/users/entities/user.entity'; - -import { SendableUser } from 'src/users/sendableUsers'; - import { Repository, Brackets } from 'typeorm'; import { CreateFriendshipDto } from './dto/create-friendship.dto'; import { Friendship, FriendshipStatus } from './entities/friendship.entity'; @@ -77,7 +74,6 @@ export class FriendshipService { ) }), ) - // .andWhere('friendship.status != :status', {status : FriendshipStatus.BLOCKED}) .getOne() // console.log('END Find one friend by username: ') @@ -85,8 +81,6 @@ export class FriendshipService { if (!friendship) { throw new HttpException(`There is no such friendship`, HttpStatus.NOT_FOUND); - // throw new HttpException(`There is no such friendship`, HttpStatus.NO_CONTENT); - // throw new HttpException(`There is no such friendship`, 204); } return new SendableFriendship(friendship); } diff --git a/srcs/requirements/svelte/api_front/src/pages/profile/ProfileUsers.svelte b/srcs/requirements/svelte/api_front/src/pages/profile/ProfileUsers.svelte index 1e9451d8..f5a215fb 100644 --- a/srcs/requirements/svelte/api_front/src/pages/profile/ProfileUsers.svelte +++ b/srcs/requirements/svelte/api_front/src/pages/profile/ProfileUsers.svelte @@ -60,6 +60,8 @@ myFriendships = await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/network/myfriends`) .then((response) => { if (!response.ok) { + if (response.status === 404) + return [] throw new Error("HTTP " + response.status); } return response.json(); @@ -74,6 +76,8 @@ requestsMade = await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/network/pending`) .then((response) => { if (!response.ok) { + if (response.status === 404) + return [] throw new Error("HTTP " + response.status); } return response.json(); @@ -88,6 +92,8 @@ requestsRecieved = await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/network/received`) .then((response) => { if (!response.ok) { + if (response.status === 404) + return [] throw new Error("HTTP " + response.status); } return response.json(); @@ -102,6 +108,8 @@ blockedUsers = await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/network/blocked`) .then((response) => { if (!response.ok) { + if (response.status === 404) + return [] throw new Error("HTTP " + response.status); } return response.json(); @@ -118,23 +126,16 @@ friendshipStatusFull = await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/network/myfriends?username=${aUsername}`) .then((response) => { if (!response.ok) { - console.log("response not ok : ") - console.log({...response}) - // throw new Error("HTTP " + response.status); + if (response.status === 404) + return [] + throw new Error("HTTP " + response.status); } - // else { - console.log("response ok : ") - console.log({...response}) return response.json(); - // } }) .catch((error) => { - console.log("catching things") console.log("catch fetchFriendshipFull: ", error); return []; }); - // console.log('friendshipFull: ') - // console.log({...friendshipStatusFull}) }; const sendFriendRequest = async (aUsername) => { @@ -303,17 +304,6 @@ await fetchAllUsers_Wrapper(); fetchFriendshipFull(usernameBeingViewed); } - - - // if (usernameBeingViewed) { - // let found = allUsers.find( - // (e) => e.username === usernameBeingViewed - // ); - // if (!found) { - // usernameBeingViewed = null; - // friendshipStatusFull = null; - // } - // } }; @@ -382,6 +372,8 @@ + +