From 115b7d834118aa944700f6242b02c5031be130ce Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Sat, 31 May 2025 16:31:40 +0200 Subject: [PATCH 01/10] feat: remove old utils in favor of api composable --- composables/api.ts | 57 ++++++++++++++++++++++++++++++++++++++++++++ utils/fetchMember.ts | 6 ----- utils/fetchUser.ts | 6 ----- 3 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 composables/api.ts delete mode 100644 utils/fetchMember.ts delete mode 100644 utils/fetchUser.ts diff --git a/composables/api.ts b/composables/api.ts new file mode 100644 index 0000000..f1ac525 --- /dev/null +++ b/composables/api.ts @@ -0,0 +1,57 @@ +import type { ChannelResponse, GuildResponse, MessageResponse } from "~/types/interfaces"; + +export const useApi = () => { + async function fetchGuilds(guildId: string): Promise { + return await fetchWithApi(`/guilds`); + } + + async function fetchGuild(guildId: string): Promise { + return await fetchWithApi(`/guilds/${guildId}`); + } + + async function fetchChannels(guildId: string): Promise { + return await fetchWithApi(`/guilds/${guildId}/channels`); + } + + async function fetchChannel(channelId: string): Promise { + return await fetchWithApi(`/channels/${channelId}`) + } + + + async function fetchMembers(guildId: string) { + return await fetchWithApi(`/guilds/${guildId}/members`); + } + + async function fetchMember(guildId: string, memberId: string) { + return await fetchWithApi(`/guilds/${guildId}/members/${memberId}`); + } + + async function fetchUsers(userId: string) { + return await fetchWithApi(`/users`); + } + + async function fetchUser(userId: string) { + return await fetchWithApi(`/users/${userId}`); + } + + async function fetchMessages(channelId: string): Promise { + return await fetchWithApi(`/channels/${channelId}/messages`); + } + + async function fetchMessage(channelId: string, messageId: string): Promise { + return await fetchWithApi(`/channels/${channelId}/messages/${messageId}`); + } + + return { + fetchGuilds, + fetchGuild, + fetchChannels, + fetchChannel, + fetchMembers, + fetchMember, + fetchUsers, + fetchUser, + fetchMessages, + fetchMessage + } +} diff --git a/utils/fetchMember.ts b/utils/fetchMember.ts deleted file mode 100644 index 8f4a9e4..0000000 --- a/utils/fetchMember.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { UserResponse } from "~/types/interfaces" - -export default async (serverId: string, memberId: string): Promise => { - const user = await fetchWithApi(`/guilds/${serverId}/members/${memberId}`) as UserResponse; - return user; -} diff --git a/utils/fetchUser.ts b/utils/fetchUser.ts deleted file mode 100644 index d509fe0..0000000 --- a/utils/fetchUser.ts +++ /dev/null @@ -1,6 +0,0 @@ -import type { UserResponse } from "~/types/interfaces" - -export default async (serverId: string, userId: string): Promise => { - const user = await fetchWithApi(`/users/${userId}`) as UserResponse; - return user; -} From 9a84315b64fe3ed3975cc2ef566d1bbef0063ede Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Sat, 31 May 2025 16:32:04 +0200 Subject: [PATCH 02/10] fix: apiBase not including api version when automatically fetched --- layouts/auth.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/auth.vue b/layouts/auth.vue index 1c05f2d..f12da45 100644 --- a/layouts/auth.vue +++ b/layouts/auth.vue @@ -67,7 +67,7 @@ if (status.value == "success" && gorbTxt.value) { console.log("got gorb.txt:", gorbTxt.value); const parsed = parseWellKnown(gorbTxt.value as string); if (parsed.ApiBaseUrl) { - apiBase.value = parsed.ApiBaseUrl; + apiBase.value = `${parsed.ApiBaseUrl}/${apiVersion}`; console.log("set apiBase to:", parsed.ApiBaseUrl); } } else { From 3fd28ed3fc1c877a274c4df9272a3857c24caabe Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Sat, 31 May 2025 16:32:51 +0200 Subject: [PATCH 03/10] fix: /guilds/me variable expecting wrong response object type --- layouts/client.vue | 7 +++---- types/interfaces.ts | 8 ++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/layouts/client.vue b/layouts/client.vue index 312b0a5..6f82bf3 100644 --- a/layouts/client.vue +++ b/layouts/client.vue @@ -11,7 +11,7 @@
- +
@@ -21,12 +21,11 @@ From 00d6eb0a00d6fa57868e38128bc190ef64611b93 Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Sat, 31 May 2025 17:11:08 +0200 Subject: [PATCH 06/10] fix: missing return type in some fetch functions --- composables/api.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composables/api.ts b/composables/api.ts index f1ac525..c74f8f3 100644 --- a/composables/api.ts +++ b/composables/api.ts @@ -1,7 +1,7 @@ -import type { ChannelResponse, GuildResponse, MessageResponse } from "~/types/interfaces"; +import type { ChannelResponse, GuildMemberResponse, GuildResponse, MessageResponse } from "~/types/interfaces"; export const useApi = () => { - async function fetchGuilds(guildId: string): Promise { + async function fetchGuilds(): Promise { return await fetchWithApi(`/guilds`); } @@ -18,15 +18,15 @@ export const useApi = () => { } - async function fetchMembers(guildId: string) { + async function fetchMembers(guildId: string): Promise { return await fetchWithApi(`/guilds/${guildId}/members`); } - async function fetchMember(guildId: string, memberId: string) { + async function fetchMember(guildId: string, memberId: string): Promise { return await fetchWithApi(`/guilds/${guildId}/members/${memberId}`); } - async function fetchUsers(userId: string) { + async function fetchUsers() { return await fetchWithApi(`/users`); } From 1c5b13632314156e71098a7bdc3400fd76b945ce Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Sat, 31 May 2025 17:12:07 +0200 Subject: [PATCH 07/10] feat: change to fetch guild members list and improve appearance of members list --- .../[serverId]/channels/[channelId].vue | 63 ++++--------------- 1 file changed, 13 insertions(+), 50 deletions(-) diff --git a/pages/servers/[serverId]/channels/[channelId].vue b/pages/servers/[serverId]/channels/[channelId].vue index ac36105..4f3e4ec 100644 --- a/pages/servers/[serverId]/channels/[channelId].vue +++ b/pages/servers/[serverId]/channels/[channelId].vue @@ -26,9 +26,9 @@
- - - {{ member.displayName }} + + + {{ member.user.display_name ?? member.user.username }}
@@ -52,53 +52,9 @@ import type { ChannelResponse, GuildResponse, MessageResponse } from "~/types/in //const servers = await fetchWithApi("/servers") as { uuid: string, name: string, description: string }[]; //console.log("channelid: servers:", servers); -const members = [ - { - id: "3287484395", - displayName: "SauceyRed", - avatar: "" - }, - { - id: "3287484395", - displayName: "JustTemmie", - avatar: "" - }, - { - id: "3287484395", - displayName: "GOIN!!!!!!", - avatar: "" - }, - { - id: "3287484395", - displayName: "SauceyRed", - avatar: "" - }, - { - id: "3287484395", - displayName: "Hatsune Miku Official", - avatar: "" - }, - { - id: "3287484395", - displayName: "Hatsune Miku Official", - avatar: "" - }, - { - id: "3287484395", - displayName: "Hatsune Miku Official", - avatar: "" - }, - { - id: "3287484395", - displayName: "SauceyRed", - avatar: "" - }, - { - id: "3287484395", - displayName: "SauceyRed", - avatar: "" - } -]; + +const { fetchMembers } = useApi(); +const members = await fetchMembers(route.params.serverId as string); onMounted(async () => { console.log("channelid: set loading to true"); @@ -129,6 +85,7 @@ function toggleInvitePopup(e: Event) { align-items: center; margin-top: .5em; margin-bottom: .5em; + gap: .5em; } #members-list { @@ -153,4 +110,10 @@ function toggleInvitePopup(e: Event) { gap: 1dvh; } +.member-avatar { + height: 2.3em; + width: 2.3em; + border-radius: 50%; +} + \ No newline at end of file From 4b2c3af5e552eec91a027a240dd7da589916b6fb Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Sat, 31 May 2025 17:13:59 +0200 Subject: [PATCH 08/10] feat: change styling of message area a bit --- components/MessageArea.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/MessageArea.vue b/components/MessageArea.vue index 4259365..ff523cf 100644 --- a/components/MessageArea.vue +++ b/components/MessageArea.vue @@ -175,6 +175,8 @@ onMounted(async () => { padding-bottom: 1dvh; padding-top: 1dvh; margin-bottom: 1dvh; + margin-left: 1dvw; + margin-right: 1dvw; } #message-form { @@ -196,6 +198,8 @@ onMounted(async () => { display: flex; flex-direction: column; gap: 1dvh; + padding-left: 1dvw; + padding-right: 1dvw; } #submit-button { From 417a558109be5cba5f72a804026d7f1168c2da0b Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Sun, 1 Jun 2025 00:59:50 +0200 Subject: [PATCH 09/10] feat: update /me/guilds object response type --- layouts/client.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/layouts/client.vue b/layouts/client.vue index 6f82bf3..6c629da 100644 --- a/layouts/client.vue +++ b/layouts/client.vue @@ -11,7 +11,7 @@
- +
@@ -21,11 +21,11 @@