diff --git a/README.md b/README.md index ecdb2d5..b86a3a8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # Nuxt Minimal Starter - - Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more. ## Setup diff --git a/app.vue b/app.vue index fbc6572..9e6e124 100644 --- a/app.vue +++ b/app.vue @@ -1,7 +1,7 @@ @@ -12,12 +12,6 @@ const banner = useState("banner", () => false); \ No newline at end of file diff --git a/components/Channel.vue b/components/Channel.vue index 1828641..a41974a 100644 --- a/components/Channel.vue +++ b/components/Channel.vue @@ -1,11 +1,11 @@ diff --git a/pages/settings.vue b/pages/settings.vue deleted file mode 100644 index 5db18fe..0000000 --- a/pages/settings.vue +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 07816d4..4d4de9d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,12 +20,6 @@ importers: '@pinia/nuxt': specifier: 0.11.0 version: 0.11.0(magicast@0.3.5)(pinia@3.0.2(typescript@5.8.3)(vue@3.5.13(typescript@5.8.3))) - dompurify: - specifier: ^3.2.6 - version: 3.2.6 - marked: - specifier: ^15.0.12 - version: 15.0.12 nuxt: specifier: ^3.17.0 version: 3.17.0(@netlify/blobs@8.2.0)(@parcel/watcher@2.5.1)(@types/node@22.15.3)(db0@0.3.2)(eslint@9.25.1(jiti@2.4.2))(ioredis@5.6.1)(lightningcss@1.29.2)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.40.1)(terser@5.39.0)(typescript@5.8.3)(vite@6.3.3(@types/node@22.15.3)(jiti@2.4.2)(lightningcss@1.29.2)(terser@5.39.0)(yaml@2.7.1))(yaml@2.7.1) @@ -1205,9 +1199,6 @@ packages: '@types/triple-beam@1.3.5': resolution: {integrity: sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==} - '@types/trusted-types@2.0.7': - resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} - '@types/yauzl@2.10.3': resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} @@ -2122,9 +2113,6 @@ packages: resolution: {integrity: sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==} engines: {node: '>= 4'} - dompurify@3.2.6: - resolution: {integrity: sha512-/2GogDQlohXPZe6D6NOgQvXLPSYBqIWMnZ8zzOhn09REE4eyAzb+Hed3jhoM9OkuaJ8P6ZGTTVWQKAi8ieIzfQ==} - domutils@3.2.2: resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==} @@ -3104,11 +3092,6 @@ packages: resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} engines: {node: '>=8'} - marked@15.0.12: - resolution: {integrity: sha512-8dD6FusOQSrpv9Z1rdNMdlSgQOIP880DHqnohobOmYLElGEqAL/JvxvuxZO16r4HtjTlfPRDC1hbvxC9dPN2nA==} - engines: {node: '>= 18'} - hasBin: true - math-intrinsics@1.1.0: resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} engines: {node: '>= 0.4'} @@ -6111,9 +6094,6 @@ snapshots: '@types/triple-beam@1.3.5': {} - '@types/trusted-types@2.0.7': - optional: true - '@types/yauzl@2.10.3': dependencies: '@types/node': 22.15.3 @@ -7102,10 +7082,6 @@ snapshots: dependencies: domelementtype: 2.3.0 - dompurify@3.2.6: - optionalDependencies: - '@types/trusted-types': 2.0.7 - domutils@3.2.2: dependencies: dom-serializer: 2.0.0 @@ -8194,8 +8170,6 @@ snapshots: dependencies: semver: 6.3.1 - marked@15.0.12: {} - math-intrinsics@1.1.0: {} mdn-data@2.0.28: {} diff --git a/public/favicon.ico b/public/favicon.ico index b3d28fa..18993ad 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/types/interfaces.ts b/types/interfaces.ts index e451a4b..c840a68 100644 --- a/types/interfaces.ts +++ b/types/interfaces.ts @@ -23,14 +23,6 @@ export interface GuildResponse { member_count: number } -export interface GuildMemberResponse { - uuid: string, - nickname: string, - user_uuid: string, - guild_uuid: string, - user: UserResponse -} - export interface ChannelResponse { uuid: string, guild_uuid: string, @@ -58,8 +50,6 @@ export interface UserResponse { username: string, display_name: string | null, avatar: string | null, - pronouns: string | null, - about: string | null, email?: string, email_verified?: boolean } @@ -72,14 +62,3 @@ export interface StatsResponse { email_verification_required: boolean, build_number: string } - -export interface ScrollPosition { - scrollHeight: number, - scrollWidth: number, - scrollTop: number, - scrollLeft: number - offsetHeight: number, - offsetWidth: number, - offsetTop: number, - offsetLeft: number -} diff --git a/utils/fetchMember.ts b/utils/fetchMember.ts new file mode 100644 index 0000000..8f4a9e4 --- /dev/null +++ b/utils/fetchMember.ts @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..d509fe0 --- /dev/null +++ b/utils/fetchUser.ts @@ -0,0 +1,6 @@ +import type { UserResponse } from "~/types/interfaces" + +export default async (serverId: string, userId: string): Promise => { + const user = await fetchWithApi(`/users/${userId}`) as UserResponse; + return user; +} diff --git a/utils/fetchWithApi.ts b/utils/fetchWithApi.ts index 4089db8..79fdae8 100644 --- a/utils/fetchWithApi.ts +++ b/utils/fetchWithApi.ts @@ -9,6 +9,8 @@ export default async (path: string, options: NitroFetchOptions = {}) path = path.slice(0, path.lastIndexOf("/")); } console.log("formatted path:", path); + const accessToken = useCookie("access_token"); + console.log("access token:", accessToken.value); const apiBase = useCookie("api_base").value; const apiVersion = useRuntimeConfig().public.apiVersion; console.log("heyoooo") @@ -19,24 +21,23 @@ export default async (path: string, options: NitroFetchOptions = {}) } console.log("path:", path) const { revoke, refresh } = useAuth(); - + console.log("access token 2:", accessToken.value); + let headers: HeadersInit = {}; - - + + if (accessToken.value) { + headers = { + ...options.headers, + "Authorization": `Bearer ${accessToken.value}` + }; + } else { + headers = { + ...options.headers + }; + } + let reauthFailed = false; while (!reauthFailed) { - const accessToken = useCookie("access_token"); - console.log("access token:", accessToken.value); - if (accessToken.value) { - headers = { - ...options.headers, - "Authorization": `Bearer ${accessToken.value}` - }; - } else { - headers = { - ...options.headers - }; - } try { console.log("fetching:", URL.parse(apiBase + path)); const res = await $fetch(URL.parse(apiBase + path)!.href, { @@ -73,10 +74,9 @@ export default async (path: string, options: NitroFetchOptions = {}) console.log("Path is refresh endpoint, throwing error"); throw error; } - } else { - console.log("throwing error:", error); - throw error; } + console.log("throwing error"); + throw error; } } } diff --git a/utils/getScrollPosition.ts b/utils/getScrollPosition.ts deleted file mode 100644 index 1f4a99f..0000000 --- a/utils/getScrollPosition.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { ScrollPosition } from "~/types/interfaces"; - -export default (element: HTMLElement): ScrollPosition => { - return { - scrollHeight: element.scrollHeight, - scrollWidth: element.scrollWidth, - scrollTop: element.scrollTop, - scrollLeft: element.scrollLeft, - offsetHeight: element.offsetHeight, - offsetWidth: element.offsetWidth, - offsetTop: element.offsetTop, - offsetLeft: element.offsetLeft - }; -} diff --git a/utils/scrollToBottom.ts b/utils/scrollToBottom.ts index 8064bd8..aca99b4 100644 --- a/utils/scrollToBottom.ts +++ b/utils/scrollToBottom.ts @@ -1,6 +1,6 @@ -export default (element: HTMLElement) => { - if (element) { - element.scrollTo({ top: element.scrollHeight }); +export default (element: Ref) => { + if (element.value) { + element.value.scrollTo({ top: element.value.scrollHeight }); return; } } diff --git a/utils/setScrollPosition.ts b/utils/setScrollPosition.ts deleted file mode 100644 index c7ddfd2..0000000 --- a/utils/setScrollPosition.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { ScrollPosition } from "~/types/interfaces"; - -export default (element: HTMLElement, scrollPosition: ScrollPosition) => { - return element.scrollTo({ top: scrollPosition.scrollTop, left: scrollPosition.scrollLeft }); -}