ok so i think i need to change a whole bunch of stuff all over in the User module and Friendship module, namely that we should be searching the DB by ID's not Usernames... currently my Blocking of a user doesn't wquite work cuz findAll() sends ID to findIfUserIsBlockedOrHasBlocked() when it should be sending usernames, but everything else sends Usernames so i'm saving now in case changing everything fucks everything up...

This commit is contained in:
Me
2022-12-23 23:36:04 +01:00
parent 139da075da
commit 7e906de128
4 changed files with 153 additions and 31 deletions

View File

@@ -2,7 +2,6 @@
import { onMount } from "svelte";
import { binding_callbacks, empty } from "svelte/internal"; // WTF is this?
import App from "../../App.svelte";
import Button from "../../pieces/Button.svelte";
import DisplayAUser from "../../pieces/DisplayAUser.svelte";
import Tabs from "../../pieces/Tabs.svelte";
@@ -90,9 +89,13 @@
};
/**** END OF MAIN FETCH ****/
// returns everything but BLOCKED
const fetchFriendshipFull = async(aUsername) => {
console.log('fetch friendship from a username')
console.log(aUsername)
friendshipStatusFull = await fetch(`http://transcendance:8080/api/v2/network/myfriends/${aUsername}`)
.then( x => x.json());
console.log({...friendshipStatusFull})
};
@@ -106,6 +109,7 @@
})
})
.then( x => x.json())
fetchFriendshipFull(aUsername);
};
const viewAUser = async(aUsername) => {
@@ -165,8 +169,8 @@
};
const blockANonFriendUser = async(aUsername) => {
console.log('Block someone username')
console.log({...aUsername})
console.log('Block a non friend user, their username')
console.log(aUsername)
const blockResp = await fetch("http://transcendance:8080/api/v2/network/myfriends", {
method : "POST",
@@ -187,6 +191,8 @@
};
const blockAFriend = async(relationshipId) => {
console.log('blocking a friend, the relationshipID')
console.log(relationshipId)
const resp = await fetch(`http://transcendance:8080/api/v2/network/myfriends/${relationshipId}/block`, {method: "PATCH"})
.then( x => x.json() );
console.log('blocked a user response')
@@ -279,7 +285,7 @@
<div class="tip">You have not Blocked any Users</div>
{/if}
{#each blockedUsers as aUser}
<div class="sidebar-item" on:click={() => viewAUser(aUser.senderUsername)}>{aUser.senderUsername}</div>
<div class="sidebar-item" on:click={() => viewAUser(aUser.receiverUsername)}>{aUser.receiverUsername}</div>
<div class="status sidebar-item">{aUser.status}</div>
<br>
{/each}