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