a few small fixes, about to add 404 exceptions most places i do fetches
This commit is contained in:
@@ -85,6 +85,8 @@ 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);
|
||||
}
|
||||
|
||||
@@ -118,14 +118,23 @@
|
||||
friendshipStatusFull = await fetch(`http://${process.env.WEBSITE_HOST}:${process.env.WEBSITE_PORT}/api/v2/network/myfriends?username=${aUsername}`)
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error("HTTP " + response.status);
|
||||
}
|
||||
console.log("response not ok : ")
|
||||
console.log({...response})
|
||||
// throw new Error("HTTP " + response.status);
|
||||
}
|
||||
// else {
|
||||
console.log("response ok : ")
|
||||
console.log({...response})
|
||||
return response.json();
|
||||
// }
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error) => {
|
||||
console.log("catching things")
|
||||
console.log("catch fetchFriendshipFull: ", error);
|
||||
return [];
|
||||
});
|
||||
// console.log('friendshipFull: ')
|
||||
// console.log({...friendshipStatusFull})
|
||||
};
|
||||
|
||||
const sendFriendRequest = async (aUsername) => {
|
||||
@@ -274,6 +283,7 @@
|
||||
const unblockAUser = async (relationshipId) => {
|
||||
// it's basically the same as unfriending someone cuz unfriending them means the relationship is deleted
|
||||
await unfriend(relationshipId);
|
||||
await fetchAll();
|
||||
activeTabItem = activeTabItem;
|
||||
};
|
||||
|
||||
@@ -289,8 +299,21 @@
|
||||
await fetchBlockedUsers();
|
||||
console.log("fetching blocked users");
|
||||
}
|
||||
if (usernameBeingViewed)
|
||||
if (usernameBeingViewed) {
|
||||
await fetchAllUsers_Wrapper();
|
||||
fetchFriendshipFull(usernameBeingViewed);
|
||||
}
|
||||
|
||||
|
||||
// if (usernameBeingViewed) {
|
||||
// let found = allUsers.find(
|
||||
// (e) => e.username === usernameBeingViewed
|
||||
// );
|
||||
// if (!found) {
|
||||
// usernameBeingViewed = null;
|
||||
// friendshipStatusFull = null;
|
||||
// }
|
||||
// }
|
||||
};
|
||||
|
||||
</script>
|
||||
@@ -470,9 +493,4 @@
|
||||
}
|
||||
|
||||
|
||||
.error{
|
||||
font-size: 0.8em;
|
||||
font-weight: bold;
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -6,16 +6,20 @@
|
||||
|
||||
export let aUsername;
|
||||
export let loaded = false;
|
||||
let user;
|
||||
let aUser;
|
||||
|
||||
onMount( async() => {
|
||||
aUser = await fetchUser(aUsername);
|
||||
})
|
||||
|
||||
$: aUsername, fetchUser(aUsername);
|
||||
const updateUser = async(aUsername) => {
|
||||
aUser = await fetchUser(aUsername);
|
||||
};
|
||||
|
||||
$: aUsername, updateUser(aUsername);
|
||||
|
||||
$: {
|
||||
if (user === undefined)
|
||||
if (aUser === undefined)
|
||||
loaded = false;
|
||||
else
|
||||
loaded = true;
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
let rank = '';
|
||||
let avatar;
|
||||
// avatar needs to be updated!!!
|
||||
console.log('Generate User Display, BEFORE on mount ' + avatar)
|
||||
console.log('user:')
|
||||
console.log('Generate User Display user:')
|
||||
console.log({...user})
|
||||
// console.log(user)
|
||||
let errors = {avatar: ''};
|
||||
@@ -18,15 +17,20 @@
|
||||
avatar = await fetchAvatar(user.username);
|
||||
})
|
||||
|
||||
const updateAvatar = async() => {
|
||||
avatar = await fetchAvatar(user.username);
|
||||
};
|
||||
|
||||
$: user, updateAvatar();
|
||||
|
||||
/**** THIS IS BASICALLY ALL THE RANK LOGIC ERIC HAS MADE ****/
|
||||
|
||||
if (user.loseGame > user.winGame) {
|
||||
rank = 'Bitch Ass Loser!'
|
||||
} else if (user.loseGame === user.winGame) {
|
||||
if (user.stats.loseGame > user.stats.winGame) {
|
||||
rank = "Come on, you can do better"
|
||||
} else if (user.stats.loseGame === user.stats.winGame) {
|
||||
rank = 'Fine i guess...'
|
||||
} else {
|
||||
rank = 'Yea you da Boss!'
|
||||
rank = 'You da Boss!'
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,9 +12,11 @@ import { fetchUser } from "../pieces/utils";
|
||||
async function checkLogin(detail) {
|
||||
const user = await fetchUser();
|
||||
if (!user || !user.username) {
|
||||
console.log('failed to be logged in')
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
console.log('successfully logged in')
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user