feat: finish entire friends menu
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
ci/woodpecker/pr/build-and-publish Pipeline was successful

This commit is contained in:
Twig 2025-07-11 01:45:24 +02:00
parent 34976b4f50
commit 0562127e4a
No known key found for this signature in database
7 changed files with 243 additions and 5 deletions

View file

@ -37,6 +37,14 @@ export const useApi = () => {
return await fetchWithApi('/me/friends')
}
async function addFriend(username: string): Promise<void> {
await fetchWithApi('/me/friends', { method: "POST", body: { username } });
}
async function removeFriend(userId: string): Promise<void> {
await fetchWithApi(`/me/friends/${userId}`, { method: "DELETE" });
}
async function fetchMessages(channelId: string, options?: { amount?: number, offset?: number }): Promise<MessageResponse[] | undefined> {
return await fetchWithApi(`/channels/${channelId}/messages`, { query: { amount: options?.amount ?? 100, offset: options?.offset ?? 0 } });
}
@ -64,6 +72,8 @@ export const useApi = () => {
fetchUsers,
fetchUser,
fetchFriends,
addFriend,
removeFriend,
fetchMessages,
fetchMessage,
fetchInstanceStats,