Compare commits

...
Sign in to create a new pull request.

78 commits
dev ... main

Author SHA1 Message Date
cca2c5ffd9 chore: CI thingy
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-23 21:50:40 +02:00
8102412ef2 chore: commit to make the CI work
the CI server was down during the last commit
2025-06-23 21:46:55 +02:00
6141cac41a Merge branch 'settings-page'
All checks were successful
ci/woodpecker/manual/build-and-publish Pipeline was successful
co-authored-by: JustTemmie <git@beaver.mom>
2025-06-23 21:11:08 +02:00
9fd9fb6744 feat: code polishing
co-authored-by: JustTemmie <git@beaver.mom>
co-authored-by: SauceyRed <saucey@saucey.red>
2025-06-23 20:46:05 +02:00
714f75ce12 feat: update button component
co-authored-by: JustTemmie <git@beaver.mom>
2025-06-23 20:02:09 +02:00
5560680635
feat: use dynamic units, minor refactoring 2025-06-11 17:42:35 +02:00
010472c83d
feat: implement scroll position retention 2025-06-07 06:12:47 +02:00
acca8468f0
feat: make <NuxtPage> keepalive 2025-06-07 06:12:46 +02:00
61df171c59
feat: create function to push messages to chat 2025-06-07 06:12:46 +02:00
2c76edaa32
feat: update scrollToBottom() 2025-06-07 06:12:46 +02:00
ccefc8ca19
feat: remove useless css properties 2025-06-07 06:12:46 +02:00
cca348b476
feat: add spacing between grouped messages 2025-06-07 06:12:45 +02:00
c0f4697d00
feat: move some colors to root variables 2025-06-07 06:12:45 +02:00
774e10d68c
fix: automatic auth refresh
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-06 01:57:19 +02:00
d49d533724
feat: change members list back to using flex display
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-06 01:56:15 +02:00
3899843a7c
feat: change message area back to using flex display, improvement for UI 2025-06-06 01:55:18 +02:00
22b43cde79
feat: make profile settings headings into block labels for accessibility
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
ci/woodpecker/pr/build-and-publish Pipeline was successful
2025-06-03 22:04:05 +02:00
d22e77ed14
feat: improve appearance of members list, same method as messages 2025-06-03 20:53:30 +02:00
67e10a4387
feat: refactor to allow more markdown tags, syling changes to make lists and headings not take up as much space 2025-06-03 20:52:42 +02:00
263c823ceb
fix: tabIndex not working after changing messages to use "display: contents;" 2025-06-03 20:50:56 +02:00
82fde5671d
fix: last message from user not having bottom margin 2025-06-03 20:49:41 +02:00
d986f601de
feat: improve 24-hour to 12-hour format conversion by using Date methods
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-03 20:42:34 +02:00
d85eb03ad0
feat: change message history grids to fix scaling of message timestamps
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-03 16:18:13 +02:00
a56e12149b
fix: modify message css to avoid weird line spacing
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-03 06:15:51 +02:00
a38589615b
chore: finnish merge
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
ci/woodpecker/pr/build-and-publish Pipeline was successful
2025-06-02 13:14:08 +02:00
cb1979a941
Merge branch 'settings-page' of ssh://git.gorb.app:2022/gorb/frontend into settings-page 2025-06-02 13:13:44 +02:00
acc4fa14b7
feat: finish up the my account section for now 2025-06-02 13:10:42 +02:00
8a3bb89f8a
Merge branch 'main' into settings-page 2025-06-02 12:36:20 +02:00
4b1f1266b0
fix: type hinting 2025-06-02 12:36:04 +02:00
76952922bf
feat: add tabbing for channels list, members list, and messages
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-02 11:40:57 +02:00
c7e7f33240
feat: add sanitized ref variable
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-02 11:06:08 +02:00
2008033216
feat: add DOMPurify and marked packages
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-02 11:03:54 +02:00
63b780e5ab
feat: implement basic markdown for messages
Some checks failed
ci/woodpecker/push/build-and-publish Pipeline failed
2025-06-02 00:57:13 +02:00
35852d8cad
feat: make URLs in messages become links
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 23:10:08 +02:00
a8e8c6b2ef
feat: define expected types for pfp input element
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 20:34:40 +02:00
0ddddd210e
feat: fucking explode i hate this
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 20:19:04 +02:00
622abc9155
feat: profile page, EXCEPT FUCKING AVATARS AAAAAHHH
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 19:24:50 +02:00
256889a573
feat: favicon!! 2025-06-01 17:46:09 +02:00
6182e00dd9
feat: decrease top padding of members container
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 17:38:03 +02:00
e8d37af75e
feat: update appearance of members list
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 17:35:36 +02:00
532aba5c21
feat: merge two #member-list blocks 2025-06-01 17:03:19 +02:00
f6523ae97f
feat: remove unnecessary styles from client layout 2025-06-01 17:02:58 +02:00
626c1c8453
fix: older messages loading in reverse order
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 16:58:53 +02:00
82796377ee
feat: change non-grouped messages to have margin-top instead of margin-bottom
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 16:57:56 +02:00
cb5360c687
Merge branch 'main' into settings-page 2025-06-01 16:38:02 +02:00
a2c04af8ce
feat: basic user popup implemented
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 16:36:59 +02:00
9fee630a68
fix: some messages not getting type correctly due to nextTick() use
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 16:23:42 +02:00
2c2013fa81
feat: update offset for fetching older messages 2025-06-01 16:22:51 +02:00
5b1d25807e
feat: fix messages not grouping correctly and implement scrolling for loading previous messages
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 16:13:46 +02:00
fc266ffcc3
feat: log out button should work?
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 12:20:21 +02:00
162ca6833f feat: change colour of focused settings category
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 07:28:09 +02:00
39fb0a9eab feat: start of "My Account" page, need API help
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 07:15:20 +02:00
705b37fa06 feat: button components
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 06:13:00 +02:00
5012517e9b feat: Fundementals for settings pages
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 05:04:38 +02:00
55f4f0401b
fix: v not included before API version number
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 01:44:18 +02:00
80f05bb514
feat: make redirects replace current url so you can go back to previous page without being immediately redirected
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 01:42:18 +02:00
038b1af44e
fix: registration and registration detection handling 2025-06-01 01:41:36 +02:00
febdbb9421
feat: add query parameters options to fetchMessages function
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-06-01 01:00:57 +02:00
417a558109
feat: update /me/guilds object response type 2025-06-01 00:59:50 +02:00
4b2c3af5e5
feat: change styling of message area a bit 2025-05-31 17:13:59 +02:00
1c5b136323
feat: change to fetch guild members list and improve appearance of members list 2025-05-31 17:12:07 +02:00
00d6eb0a00
fix: missing return type in some fetch functions 2025-05-31 17:11:08 +02:00
abf3b248c4
feat: redirect to first channel in list when going to server url 2025-05-31 16:35:11 +02:00
5011affd49
feat: remove margin-top from message box and have it be set dynamically on last message 2025-05-31 16:34:25 +02:00
3fd28ed3fc
fix: /guilds/me variable expecting wrong response object type 2025-05-31 16:33:22 +02:00
9a84315b64
fix: apiBase not including api version when automatically fetched 2025-05-31 16:32:04 +02:00
115b7d8341
feat: remove old utils in favor of api composable 2025-05-31 16:31:40 +02:00
310b1cc2df
feat: remove unnecessary log statement
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-05-31 15:28:50 +02:00
04af2be87f
fix: message grouping when messages are received from websocket 2025-05-31 15:28:33 +02:00
4da2ede58a
feat: change grouped messages being called compact to grouped
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-05-31 14:50:44 +02:00
3c65a700ff
fix: fetching from malformed endpoints, again 2025-05-31 14:46:01 +02:00
aa710e0a4d
feat: rename some occurrences of guild back to server 2025-05-31 14:38:49 +02:00
4eeb3a8c2a
fix: fetching from malformed endpoints 2025-05-31 14:31:32 +02:00
fe1474416f
feat: change all occurrences of server with guild 2025-05-31 14:27:37 +02:00
57f31d487e
fix: apiBase not including api version
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
2025-05-31 02:55:44 +02:00
76cede3d67 Merge pull request 'Fix fetched API endpoint not being used correctly' (#4) from dev into main
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
Reviewed-on: #4
2025-05-31 00:40:21 +00:00
a2e64b432d Merge pull request 'Appearance improvements, update of endpoints, and implementation of .well-known for checking API URL' (#3) from dev into main
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
Reviewed-on: #3
2025-05-30 23:21:01 +00:00
381124f778 Merge pull request 'dev' (#2) from dev into main
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
Reviewed-on: #2
2025-05-29 14:48:11 +00:00
37 changed files with 1029 additions and 275 deletions

View file

@ -1,5 +1,7 @@
# Nuxt Minimal Starter # Nuxt Minimal Starter
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more. Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
## Setup ## Setup

10
app.vue
View file

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<Banner v-if="banner" /> <Banner v-if="banner" />
<NuxtPage /> <NuxtPage :keepalive="true" />
</div> </div>
</template> </template>
@ -12,6 +12,12 @@ const banner = useState("banner", () => false);
</script> </script>
<style> <style>
:root {
--background-color: rgb(30, 30, 30);
--main-text-color: rgb(190, 190, 190);
--outline-border: 1px solid rgb(150, 150, 150);
}
html, html,
body { body {
font-family: Arial, Helvetica, sans-serif; font-family: Arial, Helvetica, sans-serif;
@ -22,7 +28,7 @@ body {
} }
*:focus-visible { *:focus-visible {
outline: 1px solid rgb(150, 150, 150); outline: var(--outline-border);
} }
a { a {

44
components/Button.vue Normal file
View file

@ -0,0 +1,44 @@
<template>
<div @click="props.callback()" class="button" :class="props.variant + '-button'">
{{ props.text }}
</div>
</template>
<script lang="ts" setup>
const props = defineProps<{
text: string,
callback: CallableFunction,
variant?: "normal" | "scary" | "neutral",
}>();
</script>
<style scoped>
.button {
cursor: pointer;
background-color: #b35719;
color: #ffffff;
padding: 0.7dvh 1.2dvw;
font-size: 1.1em;
transition: background-color 0.2s;
border-radius: 0.7rem;
text-decoration: none;
display: inline-block;
}
.scary-button {
background-color: red;
}
.neutral-button {
background-color: grey;
}
.button:hover {
background-color: #934410;
}
</style>

View file

@ -1,11 +1,11 @@
<template> <template>
<div v-if="isCurrentChannel" class="channel-list-link-container rounded-corners current-channel"> <div v-if="isCurrentChannel" class="channel-list-link-container rounded-corners current-channel" tabindex="0">
<NuxtLink class="channel-list-link" :href="props.href"> <NuxtLink class="channel-list-link" :href="props.href" tabindex="-1">
# {{ props.name }} # {{ props.name }}
</NuxtLink> </NuxtLink>
</div> </div>
<div v-else class="channel-list-link-container rounded-corners"> <div v-else class="channel-list-link-container rounded-corners" tabindex="0">
<NuxtLink class="channel-list-link" :href="props.href"> <NuxtLink class="channel-list-link" :href="props.href" tabindex="-1">
# {{ props.name }} # {{ props.name }}
</NuxtLink> </NuxtLink>
</div> </div>

View file

@ -20,7 +20,7 @@ const route = useRoute();
async function generateInvite(): Promise<void> { async function generateInvite(): Promise<void> {
const createdInvite: InviteResponse | undefined = await fetchWithApi( const createdInvite: InviteResponse | undefined = await fetchWithApi(
`/servers/${route.params.serverId}/invites`, `/guilds/${route.params.serverId}/invites`,
{ method: "POST", body: { custom_id: "oijewfoiewf" } } { method: "POST", body: { custom_id: "oijewfoiewf" } }
); );

View file

@ -1,40 +1,37 @@
<template> <template>
<div v-if="props.type == 'normal'" class="message normal-message" :class="{ 'message-margin-bottom': props.marginBottom }"> <div v-if="props.type == 'normal'" :id="props.last ? 'last-message' : undefined" class="message normal-message">
<div class="left-column"> <div class="left-column">
<img v-if="props.img" class="message-author-avatar" :src="props.img" :alt="username"> <img v-if="props.img" class="message-author-avatar" :src="props.img" :alt="username" />
<Icon v-else name="lucide:user" class="message-author-avatar" /> <Icon v-else name="lucide:user" class="message-author-avatar" />
</div> </div>
<div class="message-data"> <div class="message-data">
<div class="message-metadata"> <div class="message-metadata">
<span class="message-author-username"> <span class="message-author-username" tabindex="0">
{{ username }} {{ username }}
</span> </span>
<span class="message-date" :title="date.toString()"> <span class="message-date" :title="date.toString()">
{{ messageDate }} {{ date.toLocaleTimeString(undefined, { timeStyle: "short" }) }}
</span> </span>
</div> </div>
<div class="message-text"> <div class="message-text" v-html="sanitized" tabindex="0"></div>
{{ text }}
</div> </div>
</div> </div>
</div> <div v-else ref="messageElement" :id="props.last ? 'last-message' : undefined" class="message grouped-message" :class="{ 'message-margin-bottom': props.marginBottom }">
<div v-else ref="messageElement" class="message compact-message">
<div class="left-column"> <div class="left-column">
<div> <span :class="{ 'invisible': dateHidden }" class="message-date side-message-date" :title="date.toString()">
<span :class="{ 'invisible': dateHidden }" class="message-date" :title="date.toString()"> {{ date.toLocaleTimeString(undefined, { timeStyle: "short" }) }}
{{ messageDate }}
</span> </span>
</div> </div>
</div>
<div class="message-data"> <div class="message-data">
<div class="message-text"> <div class="message-text" :class="$style['message-text']" v-html="sanitized" tabindex="0"></div>
{{ text }}
</div>
</div> </div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import DOMPurify from 'dompurify';
import { parse } from 'marked';
const props = defineProps<{ const props = defineProps<{
class?: string, class?: string,
img?: string | null, img?: string | null,
@ -42,47 +39,35 @@ const props = defineProps<{
text: string, text: string,
timestamp: number, timestamp: number,
format: "12" | "24", format: "12" | "24",
type: "normal" | "compact", type: "normal" | "grouped",
marginBottom: boolean marginBottom: boolean,
last: boolean
}>(); }>();
const messageDate = ref<string>();
const messageElement = ref<HTMLDivElement>(); const messageElement = ref<HTMLDivElement>();
const dateHidden = ref<boolean>(true); const dateHidden = ref<boolean>(true);
const date = new Date(props.timestamp); const date = new Date(props.timestamp);
console.log("Message.vue: message:", props.text); console.log("message:", props.text);
console.log("Message.vue: message type:", props.type); console.log("author:", props.username);
let dateHour = date.getHours(); const sanitized = ref<string>();
let dateMinute = date.getMinutes();
if (props.format == "12") {
if (dateHour > 12) {
dateHour = dateHour - 12;
messageDate.value = `${dateHour}:${dateMinute < 10 ? "0" + dateMinute : dateMinute} PM`
} else {
if (dateHour == 0) {
dateHour = 12;
}
messageDate.value = `${dateHour}:${dateMinute < 10 ? "0" + dateMinute : dateMinute} ${dateHour >= 0 && dateHour < 13 ? "AM" : "PM"}`
}
} else {
messageDate.value = `${dateHour}:${dateMinute < 10 ? "0" + dateMinute : dateMinute}`
}
onMounted(() => { onMounted(async () => {
const parsed = await parse(props.text, { gfm: true });
sanitized.value = DOMPurify.sanitize(parsed, { ALLOWED_TAGS: ["strong", "em", "br", "blockquote", "code", "ul", "ol", "li", "a", "h1", "h2", "h3", "h4", "h5", "h6"] });
console.log("adding listeners")
await nextTick();
messageElement.value?.addEventListener("mouseenter", (e: Event) => { messageElement.value?.addEventListener("mouseenter", (e: Event) => {
console.log("mouse enter");
dateHidden.value = false; dateHidden.value = false;
}); });
messageElement.value?.addEventListener("mouseleave", (e: Event) => { messageElement.value?.addEventListener("mouseleave", (e: Event) => {
console.log("mouse leave");
dateHidden.value = true; dateHidden.value = true;
}); });
console.log("added listeners");
}); });
//function toggleTooltip(e: Event) { //function toggleTooltip(e: Event) {
@ -96,12 +81,26 @@ onMounted(() => {
text-align: left; text-align: left;
/* border: 1px solid lightcoral; */ /* border: 1px solid lightcoral; */
display: grid; display: grid;
grid-template-columns: 1fr 19fr; grid-template-columns: 2dvw 1fr;
align-items: center; align-items: center;
column-gap: 1dvw;
width: 100%;
} }
.message-margin-bottom { .message:hover {
margin-bottom: 1dvh; background-color: rgb(20, 20, 20);
}
.normal-message {
margin-top: 1dvh;
}
.grouped-message {
margin-top: .3em;
}
#last-message {
margin-bottom: 2dvh;
} }
.message-metadata { .message-metadata {
@ -115,8 +114,8 @@ onMounted(() => {
margin-left: .5dvw; margin-left: .5dvw;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 1dvh; height: fit-content;
height: 100%; width: 100%;
} }
.message-author { .message-author {
@ -125,15 +124,15 @@ onMounted(() => {
} }
.message-author-avatar { .message-author-avatar {
height: 2.3em; width: 100%;
width: 2.3em;
border-radius: 50%; border-radius: 50%;
} }
.left-column { .left-column {
margin-right: .5dvw; display: flex;
text-align: center; text-align: center;
align-content: center; white-space: nowrap;
} }
.author-username { .author-username {
@ -147,6 +146,13 @@ onMounted(() => {
cursor: default; cursor: default;
} }
.side-message-date {
font-size: .625em;
display: flex;
align-items: center;
align-content: center;
}
/* /*
.message-date-tooltip { .message-date-tooltip {
height: 20px;; height: 20px;;
@ -154,3 +160,15 @@ onMounted(() => {
} }
*/ */
</style> </style>
<style module>
.message-text ul, h1, h2, h3, h4, h5, h6 {
padding-top: 1dvh;
padding-bottom: 1dvh;
margin: 0;
}
.message-text ul {
padding-left: 2dvw;
}
</style>

View file

@ -1,12 +1,11 @@
<template> <template>
<div id="message-area"> <div id="message-area">
<div id="messages" ref="messagesElement"> <div id="messages" ref="messagesElement">
<div v-for="(message, i) of messages"> <Message v-for="(message, i) of messages" :username="message.user.display_name ?? message.user.username"
<Message :username="message.user.display_name ?? message.user.username"
:text="message.message" :timestamp="messageTimestamps[message.uuid]" :img="message.user.avatar" :text="message.message" :timestamp="messageTimestamps[message.uuid]" :img="message.user.avatar"
format="12" :type="messagesType[message.uuid]" format="12" :type="messagesType[message.uuid]"
:margin-bottom="messages[i + 1] && messagesType[messages[i + 1].uuid] == 'normal'" /> :margin-bottom="(messages[i + 1] && messagesType[messages[i + 1].uuid] == 'normal') ?? false"
</div> :last="i == messages.length - 1" />
</div> </div>
<div id="message-box" class="rounded-corners"> <div id="message-box" class="rounded-corners">
<form id="message-form" @submit="sendMessage"> <form id="message-form" @submit="sendMessage">
@ -21,35 +20,48 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type { MessageResponse } from '~/types/interfaces'; import type { MessageResponse, ScrollPosition } from '~/types/interfaces';
import scrollToBottom from '~/utils/scrollToBottom'; import scrollToBottom from '~/utils/scrollToBottom';
const props = defineProps<{ channelUrl: string, amount?: number, offset?: number }>(); const props = defineProps<{ channelUrl: string, amount?: number, offset?: number }>();
const messageTimestamps = ref<Record<string, number>>({}); const messageTimestamps = ref<Record<string, number>>({});
const messagesType = ref<Record<string, "normal" | "compact">>({}); const messagesType = ref<Record<string, "normal" | "grouped">>({});
const messageGroupingMaxDifference = useRuntimeConfig().public.messageGroupingMaxDifference
const messagesRes: MessageResponse[] | undefined = await fetchWithApi( const messagesRes: MessageResponse[] | undefined = await fetchWithApi(
`${props.channelUrl}/messages`, `${props.channelUrl}/messages`,
{ query: { "amount": props.amount ?? 100, "offset": props.offset ?? 0 } } { query: { "amount": props.amount ?? 100, "offset": props.offset ?? 0 } }
); );
if (messagesRes) {
messagesRes.reverse();
console.log("messages res:", messagesRes.map(msg => msg.message));
const firstMessageByUsers = ref<Record<string, MessageResponse | undefined>>({});
for (const message of messagesRes) {
messageTimestamps.value[message.uuid] = uuidToTimestamp(message.uuid);
const firstMessageByUsers = ref<Record<string, MessageResponse | undefined>>({});
const previousMessage = ref<MessageResponse>();
function groupMessage(message: MessageResponse, options?: { prevMessage?: MessageResponse, reverse?: boolean }) {
messageTimestamps.value[message.uuid] = uuidToTimestamp(message.uuid);
console.log("message:", message.message); console.log("message:", message.message);
console.log("author:", message.user.username, `(${message.user.uuid})`);
if (!previousMessage.value || previousMessage.value && message.user.uuid != previousMessage.value.user.uuid) {
console.log("no previous message or author is different than last messsage's");
messagesType.value[message.uuid] = "normal";
previousMessage.value = message;
console.log("set previous message to:", previousMessage.value.message);
console.log(`setting first post by user ${message.user.username} to "${message.message}" with timestamp ${messageTimestamps.value[message.uuid]}`);
firstMessageByUsers.value[message.user.uuid] = message;
return;
}
const firstByUser = firstMessageByUsers.value[message.user.uuid]; const firstByUser = firstMessageByUsers.value[message.user.uuid];
if (firstByUser) { if (firstByUser) {
console.log("first by user exists"); console.log("first by user exists:", firstByUser);
if (message.user.uuid != firstByUser.user.uuid) { if (message.user.uuid != firstByUser.user.uuid) {
console.log("message is by new user, setting their first message") console.log("message is by new user, setting their first message")
firstMessageByUsers.value[message.user.uuid] = message; firstMessageByUsers.value[message.user.uuid] = message;
console.log("RETURNING FALSE"); console.log("RETURNING FALSE");
messagesType.value[message.uuid] = "normal"; messagesType.value[message.uuid] = "normal";
continue; return;
} }
} else { } else {
console.log("first by user doesn't exist"); console.log("first by user doesn't exist");
@ -57,14 +69,15 @@ if (messagesRes) {
firstMessageByUsers.value[message.user.uuid] = message; firstMessageByUsers.value[message.user.uuid] = message;
console.log("RETURNING FALSE"); console.log("RETURNING FALSE");
messagesType.value[message.uuid] = "normal"; messagesType.value[message.uuid] = "normal";
continue; return;
} }
const messageGroupingMaxDifference = useRuntimeConfig().public.messageGroupingMaxDifference;
const prevTimestamp = messageTimestamps.value[firstByUser.uuid]; const prevTimestamp = messageTimestamps.value[firstByUser.uuid];
const timestamp = messageTimestamps.value[message.uuid]; const timestamp = messageTimestamps.value[message.uuid];
console.log("first message timestamp:", prevTimestamp); console.log("first message timestamp:", prevTimestamp);
console.log("timestamp:", timestamp); console.log("timestamp:", timestamp);
const diff = (timestamp - prevTimestamp); const diff = Math.abs(timestamp - prevTimestamp);
console.log("min diff:", messageGroupingMaxDifference); console.log("min diff:", messageGroupingMaxDifference);
console.log("diff:", diff); console.log("diff:", diff);
const lessThanMax = diff <= messageGroupingMaxDifference; const lessThanMax = diff <= messageGroupingMaxDifference;
@ -74,13 +87,25 @@ if (messagesRes) {
console.log(`setting first post by user ${message.user.username} to "${message.message}" with timestamp ${messageTimestamps.value[message.uuid]}`) console.log(`setting first post by user ${message.user.username} to "${message.message}" with timestamp ${messageTimestamps.value[message.uuid]}`)
firstMessageByUsers.value[message.user.uuid] = message; firstMessageByUsers.value[message.user.uuid] = message;
messagesType.value[message.uuid] = "normal"; messagesType.value[message.uuid] = "normal";
continue; return;
} }
console.log("RETURNING " + lessThanMax.toString().toUpperCase()); console.log("RETURNING " + lessThanMax.toString().toUpperCase());
messagesType.value[message.uuid] = "compact"; messagesType.value[message.uuid] = "grouped";
}
if (messagesRes) {
messagesRes.reverse();
console.log("messages res:", messagesRes.map(msg => msg.message));
for (const message of messagesRes) {
groupMessage(message);
} }
} }
function pushMessage(message: MessageResponse) {
groupMessage(message);
messages.value.push(message);
}
const messages = ref<MessageResponse[]>([]); const messages = ref<MessageResponse[]>([]);
const messageInput = ref<string>(); const messageInput = ref<string>();
@ -92,6 +117,7 @@ if (messagesRes) messages.value = messagesRes;
const accessToken = useCookie("access_token").value; const accessToken = useCookie("access_token").value;
const apiBase = useCookie("api_base").value; const apiBase = useCookie("api_base").value;
const { refresh } = useAuth(); const { refresh } = useAuth();
const { fetchMessages } = useApi();
let ws: WebSocket; let ws: WebSocket;
@ -115,12 +141,14 @@ if (accessToken && apiBase) {
console.log("event data:", event.data); console.log("event data:", event.data);
console.log("message uuid:", event.data.uuid); console.log("message uuid:", event.data.uuid);
const parsedData = JSON.parse(event.data); const parsedData = JSON.parse(event.data);
messageTimestamps.value[parsedData.uuid] = uuidToTimestamp(parsedData.uuid);
messages.value.push(parsedData); console.log("parsed message type:", messagesType.value[parsedData.uuid]);
console.log("parsed message timestamp:", messageTimestamps.value[parsedData.uuid]);
pushMessage(parsedData);
await nextTick(); await nextTick();
if (messagesElement.value) { if (messagesElement.value) {
console.log("scrolling to bottom"); console.log("scrolling to bottom");
scrollToBottom(messagesElement); scrollToBottom(messagesElement.value);
} }
}); });
@ -139,20 +167,80 @@ function sendMessage(e: Event) {
} }
} }
const route = useRoute();
onMounted(async () => { onMounted(async () => {
if (import.meta.server) return;
if (messagesElement.value) { if (messagesElement.value) {
scrollToBottom(messagesElement); scrollToBottom(messagesElement.value);
let fetched = false;
const amount = messages.value.length;
let offset = messages.value.length;
messagesElement.value.addEventListener("scroll", async (e) => {
if (e.target) {
const target = e.target as HTMLDivElement;
if (target.scrollTop <= target.scrollHeight * 0.1) {
if (fetched) return;
fetched = true;
console.log("scroll height is at 10% or less");
//console.log("current oldest:", currentOldestMessage);
const olderMessages = await fetchMessages(route.params.channelId as string, { amount, offset });
if (olderMessages) {
olderMessages.reverse();
console.log("older messages:", olderMessages);
if (olderMessages.length == 0) return;
olderMessages.reverse();
for (const [i, oldMessage] of olderMessages.entries()) {
console.log("old message:", oldMessage);
messages.value.unshift(oldMessage);
for (const message of messages.value) {
groupMessage(message);
}
}
offset += offset;
}
} else {
fetched = false;
}
}
});
} }
}); });
let scrollPosition = ref<Record<string, ScrollPosition>>({});
onActivated(async () => {
await nextTick();
console.log("scroll activated");
if (messagesElement.value) {
if (scrollPosition.value[route.params.channelId as string]) {
console.log("saved scroll position:", scrollPosition.value);
setScrollPosition(messagesElement.value, scrollPosition.value[route.params.channelId as string]);
console.log("scrolled to saved scroll position");
} else {
scrollToBottom(messagesElement.value);
console.log("scrolled to bottom");
}
}
});
const router = useRouter();
router.beforeEach((to, from, next) => {
console.log("scroll hi");
if (messagesElement.value && from.params.channelId) {
scrollPosition.value[from.params.channelId as string] = getScrollPosition(messagesElement.value)
console.log("set saved scroll position to:", scrollPosition.value);
}
next()
})
</script> </script>
<style scoped> <style scoped>
#message-area { #message-area {
display: grid; display: grid;
grid-template-columns: 1fr;
grid-template-rows: 8fr 1fr; grid-template-rows: 8fr 1fr;
justify-content: space-between;
padding-left: 1dvw; padding-left: 1dvw;
padding-right: 1dvw; padding-right: 1dvw;
overflow: hidden; overflow: hidden;
@ -167,7 +255,8 @@ onMounted(async () => {
padding-bottom: 1dvh; padding-bottom: 1dvh;
padding-top: 1dvh; padding-top: 1dvh;
margin-bottom: 1dvh; margin-bottom: 1dvh;
margin-top: 2dvh; margin-left: 1dvw;
margin-right: 1dvw;
} }
#message-form { #message-form {
@ -188,7 +277,8 @@ onMounted(async () => {
overflow-y: scroll; overflow-y: scroll;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 1dvh; padding-left: 1dvw;
padding-right: 1dvw;
} }
#submit-button { #submit-button {

View file

@ -0,0 +1,14 @@
<template>
<div>
<h1>hi</h1>
<h5>TEST</h5>
<h5>TEST</h5>
</div>
</template>
<script lang="ts" setup>
</script>
<style scoped>
</style>

View file

@ -0,0 +1,12 @@
<template>
<div>
<h1>Keybinds (TBA)</h1>
</div>
</template>
<script lang="ts" setup>
</script>
<style scoped>
</style>

View file

@ -0,0 +1,12 @@
<template>
<div>
<h1>Language (TBA)</h1>
</div>
</template>
<script lang="ts" setup>
</script>
<style scoped>
</style>

View file

@ -0,0 +1,12 @@
<template>
<div>
<h1>Notifications (TBA)</h1>
</div>
</template>
<script lang="ts" setup>
</script>
<style scoped>
</style>

View file

@ -0,0 +1,155 @@
<template>
<div>
<h1>My Account</h1>
<div class="profile-container">
<div class="user-data-fields" v-if="user">
<p class="subtitle">AVATAR</p>
<Button text="Change Avatar" :callback="changeAvatar" style="margin-right: 0.8dvw;"></Button>
<Button text="Remove Avatar" :callback="removeAvatar" variant="neutral"></Button>
<label for="profile-display-name-input" class="subtitle">DISPLAY NAME</label>
<input id="profile-display-name-input" class="profile-data-input" type="text" v-model="user.display_name" placeholder="Enter display name" />
<label for="profile-username-input" class="subtitle">USERNAME</label>
<input id="profile-username-input" class="profile-data-input" type="text" v-model="user.username" placeholder="Enter username" />
<label for="profile-pronouns-input" class="subtitle">PRONOUNS</label>
<input id="profile-pronouns-input" class="profile-data-input" type="text" v-model="user.pronouns" placeholder="Enter pronouns" />
<label for="profile-about-me-input" class="subtitle">ABOUT ME</label>
<input id="profile-about-me-input" class="profile-data-input" type="text" v-model="user.about" placeholder="About me" />
<br>
<Button style="margin-top: 1dvh" text="Save Changes" :callback="saveChanges"></Button>
</div>
<UserPopup v-if="user" :user="user" class="profile-popup"></UserPopup>
</div>
<h2 style="margin-top: 8duservh">Password (and eventually authenticator)</h2>
<Button text="Reset Password (tbd)" :callback=resetPassword></Button>
<h2>Account Deletion</h2>
<Button text="Delete Account (tbd)" :callback=deleteAccount variant="scary"></Button>
</div>
</template>
<script lang="ts" setup>
import Button from '~/components/Button.vue';
import type { UserResponse } from '~/types/interfaces';
const { fetchUser } = useAuth();
const user: UserResponse | undefined = await fetchUser()
if (!user) {
alert("could not fetch user info, aborting :(")
}
let newPfpFile: File;
const saveChanges = async () => {
if (!user) return;
const formData = new FormData()
if (newPfpFile) {
formData.append("avatar", newPfpFile)
}
const bytes = new TextEncoder().encode(JSON.stringify({
display_name: user.display_name,
username: user.username,
pronouns: user.pronouns,
about: user.about,
}));
formData.append('json', new Blob([bytes], { type: 'application/json' }));
try {
await fetchWithApi('/me', {
method: 'PATCH',
body: formData
})
alert('success!!')
} catch (error: any) {
if (error?.response?.status !== 200) {
alert(`error ${error?.response?.status} met whilst trying to update profile info`)
}
}
};
const removeAvatar = async () => {
alert("TBD")
// await fetchWithApi(`/auth/reset-password`);
}
const changeAvatar = async () => {
if (!user) return;
const input = document.createElement('input');
input.type = 'file';
input.accept = 'image/*';
input.addEventListener("change", (e: Event) => {
if (input.files?.length && input.files.length > 0) {
const file = input.files[0];
if (!file) return;
newPfpFile = file
const reader = new FileReader();
reader.addEventListener("onload", () => {
if (reader.result && typeof reader.result === 'string') {
user.avatar = reader.result;
}
});
reader.readAsDataURL(file);
}
})
input.click()
}
const resetPassword = async () => {
alert("TBD")
// await fetchWithApi(`/auth/reset-password`);
}
const deleteAccount = async () => {
alert("TBD")
}
</script>
<style scoped>
.profile-container {
display: flex;
}
.subtitle {
display: block;
font-size: 0.8em;
font-weight: 800;
margin: 1.5dvh 0 0.5dvh 0.25dvw;
}
.user-data-fields {
min-width: 35dvw;
max-width: 35dvw;
}
.profile-data-input {
min-width: 30dvw;
margin: 0.07dvh;
padding: 0.1dvh 0.7dvw;
height: 2.5em;
font-size: 1em;
border-radius: 8px;
border: none;
color: white;
background-color: #54361b;
}
.profile-popup {
margin-left: 2dvw;
}
</style>

View file

@ -0,0 +1,12 @@
<template>
<div>
<h1>Connections (TBA)</h1>
</div>
</template>
<script lang="ts" setup>
</script>
<style scoped>
</style>

View file

@ -0,0 +1,12 @@
<template>
<div>
<h1>Devices (TBA)</h1>
</div>
</template>
<script lang="ts" setup>
</script>
<style scoped>
</style>

View file

@ -0,0 +1,13 @@
<template>
<div>
<h1>Privacy (TBA)</h1>
</div>
</template>
<script lang="ts" setup>
import Button from '~/components/Button.vue';
</script>
<style scoped>
</style>

85
components/UserPopup.vue Normal file
View file

@ -0,0 +1,85 @@
<template>
<div id="profile-popup">
<img v-if="props.user.avatar" id="avatar" :src="props.user.avatar" alt="profile avatar">
<div id="cover-colour"></div>
<div id="main-body">
<p id="display-name">
<strong>{{ props.user.display_name }}</strong>
</p>
<p id="username-and-pronouns">
{{ props.user.username }}
<span v-if="props.user.pronouns"> - {{ props.user.pronouns }}</span>
</p>
<div id="about-me" v-if="props.user.about">
{{ props.user.about }}
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import type { UserResponse } from '~/types/interfaces';
const { fetchMembers } = useApi();
const props = defineProps<{
user: UserResponse
}>();
</script>
<style scoped>
#profile-popup {
min-width: 300px;
max-width: 300px;
border-radius: 8px;
position: relative;
display: flex;
flex-direction: column;
}
#cover-colour {
border-radius: 12px 12px 0 0;
min-height: 60px;
background-color: #442505;
}
#main-body {
border-radius: 0 0 12px 12px;
padding: 12px;
min-height: 280px;
background-color: #4b3018;
overflow-wrap: break-word;
hyphens: manual;
}
#avatar {
width: 96px;
height: 96px;
border: 5px solid #4b3018;
border-radius: 100%;
position: absolute;
left: 16px;
top: 16px;
}
#display-name {
margin-top: 60px;
margin-bottom: 0;
font-size: 28px;
}
#username-and-pronouns {
margin: 2px;
font-size: 16px;
}
#about-me {
background-color: #34200f;
border-radius: 12px;
margin-top: 32px;
padding: 16px;
font-size: 16px;
}
</style>

56
composables/api.ts Normal file
View file

@ -0,0 +1,56 @@
import type { ChannelResponse, GuildMemberResponse, GuildResponse, MessageResponse } from "~/types/interfaces";
export const useApi = () => {
async function fetchGuilds(): Promise<GuildResponse[] | undefined> {
return await fetchWithApi(`/guilds`);
}
async function fetchGuild(guildId: string): Promise<GuildResponse | undefined> {
return await fetchWithApi(`/guilds/${guildId}`);
}
async function fetchChannels(guildId: string): Promise<ChannelResponse[] | undefined> {
return await fetchWithApi(`/guilds/${guildId}/channels`);
}
async function fetchChannel(channelId: string): Promise<ChannelResponse | undefined> {
return await fetchWithApi(`/channels/${channelId}`)
}
async function fetchMembers(guildId: string): Promise<GuildMemberResponse[] | undefined> {
return await fetchWithApi(`/guilds/${guildId}/members`);
}
async function fetchMember(guildId: string, memberId: string): Promise<GuildMemberResponse | undefined> {
return await fetchWithApi(`/guilds/${guildId}/members/${memberId}`);
}
async function fetchUsers() {
return await fetchWithApi(`/users`);
}
async function fetchUser(userId: string) {
return await fetchWithApi(`/users/${userId}`);
}
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 } });
}
async function fetchMessage(channelId: string, messageId: string): Promise<MessageResponse | undefined> {
return await fetchWithApi(`/channels/${channelId}/messages/${messageId}`);
}
return {
fetchGuilds,
fetchGuild,
fetchChannels,
fetchChannel,
fetchMembers,
fetchMember,
fetchUsers,
fetchUser,
fetchMessages,
fetchMessage
}
}

View file

@ -75,7 +75,7 @@ export const useAuth = () => {
async function fetchUser() { async function fetchUser() {
if (!accessToken.value) return; if (!accessToken.value) return;
console.log("fetchuser access token:", accessToken.value); console.log("fetchuser access token:", accessToken.value);
const res = await fetchWithApi("/users/me") as UserResponse; const res = await fetchWithApi("/me") as UserResponse;
user.value = res; user.value = res;
return user.value; return user.value;
} }
@ -88,6 +88,20 @@ export const useAuth = () => {
return user.value; return user.value;
} }
// as in email the password link
async function resetPassword() {
// ...
}
async function disableAccount() {
// ...
}
async function deleteAccount() {
// ...
}
return { return {
accessToken, accessToken,
register, register,

View file

@ -51,28 +51,17 @@
<script lang="ts" setup> <script lang="ts" setup>
import { FetchError } from 'ofetch'; import { FetchError } from 'ofetch';
import type { StatsResponse } from '~/types/interfaces';
const instanceUrl = ref<string | null | undefined>(null); const instanceUrl = ref<string | null | undefined>(null);
const instanceUrlInput = ref<string>(); const instanceUrlInput = ref<string>();
const instanceError = ref<string>(); const instanceError = ref<string>();
const requestUrl = useRequestURL(); const apiVersion = useRuntimeConfig().public.apiVersion;
const apiBase = useCookie("api_base"); const apiBase = useCookie("api_base");
const gorbTxtError = ref<string>(""); const registrationEnabled = useState("registrationEnabled", () => true);
const auth = useAuth(); const auth = useAuth();
const { status, data: gorbTxt } = await useFetch(`${requestUrl.protocol}//${requestUrl.host}/.well-known/gorb.txt`, { responseType: "text" });
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;
console.log("set apiBase to:", parsed.ApiBaseUrl);
}
} else {
gorbTxtError.value = "Failed to find that instance.";
}
onMounted(async () => { onMounted(async () => {
const cookie = useCookie("instance_url").value; const cookie = useCookie("instance_url").value;
instanceUrl.value = cookie; instanceUrl.value = cookie;
@ -92,12 +81,17 @@ async function selectInstance(e: Event) {
const parsed = parseWellKnown(res._data as string); const parsed = parseWellKnown(res._data as string);
console.log("parsed:", parsed); console.log("parsed:", parsed);
if (parsed.ApiBaseUrl) { if (parsed.ApiBaseUrl) {
apiBase.value = parsed.ApiBaseUrl; apiBase.value = `${parsed.ApiBaseUrl}/v${apiVersion}`;
console.log("set apiBase to:", parsed.ApiBaseUrl); console.log("set apiBase to:", parsed.ApiBaseUrl);
const origin = new URL(res.url).origin; const origin = new URL(res.url).origin;
instanceUrl.value = origin; instanceUrl.value = origin;
useCookie("instance_url").value = origin; useCookie("instance_url").value = origin;
console.log("set instance url to:", origin); console.log("set instance url to:", origin);
const { status, data, error } = await useFetch<StatsResponse>(`${apiBase.value}/stats`);
if (status.value == "success" && data.value) {
registrationEnabled.value = data.value.registration_enabled;
console.log("set registration enabled value to:", data.value.registration_enabled);
}
return; return;
} }
instanceError.value = "That URL is not a valid instance."; instanceError.value = "That URL is not a valid instance.";

View file

@ -11,7 +11,7 @@
<Icon name="lucide:house" class="white" size="2rem" /> <Icon name="lucide:house" class="white" size="2rem" />
</NuxtLink> </NuxtLink>
<div id="servers-list"> <div id="servers-list">
<NuxtLink v-for="server of servers" :href="`/servers/${server.uuid}`"> <NuxtLink v-for="guild of guilds" :href="`/servers/${guild.uuid}`">
<Icon name="lucide:server" class="white" size="2rem" /> <Icon name="lucide:server" class="white" size="2rem" />
</NuxtLink> </NuxtLink>
</div> </div>
@ -23,10 +23,9 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { GuildResponse } from '~/types/interfaces'; import type { GuildResponse } from '~/types/interfaces';
const loading = useState("loading", () => false); const loading = useState("loading", () => false);
const servers: GuildResponse[] | undefined = await fetchWithApi("/me/guilds"); const guilds: GuildResponse[] | undefined = await fetchWithApi("/me/guilds");
//const servers = await fetchWithApi("/servers") as { uuid: string, name: string, description: string }[]; //const servers = await fetchWithApi("/servers") as { uuid: string, name: string, description: string }[];
//console.log("servers:", servers); //console.log("servers:", servers);
@ -124,30 +123,6 @@ const members = [
grid-row: 1; grid-row: 1;
} }
#test {
grid-column: 3;
grid-row: 1;
}
.member-item {
display: flex;
justify-content: center;
align-items: center;
}
#message-history,
#members-list {
padding-top: 3dvh;
}
#message-history {
display: flex;
flex-direction: column;
justify-content: space-between;
padding-left: 3dvw;
padding-right: 3dvw;
}
#left-column { #left-column {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View file

@ -3,6 +3,25 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
const loading = useState("loading"); const loading = useState("loading");
const accessToken = useCookie("access_token").value; const accessToken = useCookie("access_token").value;
if (["/login", "/register"].includes(to.path)) { if (["/login", "/register"].includes(to.path)) {
console.log("path is login or register");
const apiBase = useCookie("api_base");
console.log("apiBase gotten:", apiBase.value);
if (!apiBase.value) {
const requestUrl = useRequestURL();
console.log("request url:", requestUrl.href);
const apiVersion = useRuntimeConfig().public.apiVersion;
console.log("api version:", apiVersion);
console.log("apiBase not set");
const { status, data: gorbTxt } = await useFetch(`${requestUrl.protocol}//${requestUrl.host}/.well-known/gorb.txt`, { responseType: "text" });
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}/v${apiVersion}`;
console.log("set apiBase to:", parsed.ApiBaseUrl);
}
}
}
if (accessToken) { if (accessToken) {
return await navigateTo("/"); return await navigateTo("/");
} }

15
middleware/server.ts Normal file
View file

@ -0,0 +1,15 @@
import type { ChannelResponse } from "~/types/interfaces";
export default defineNuxtRouteMiddleware(async (to, from) => {
const { fetchChannels } = useApi();
const guildId = to.params.serverId as string;
const channels: ChannelResponse[] | undefined = await fetchChannels(guildId);
console.log("channels:", channels);
if (channels && channels.length > 0) {
console.log("wah");
return await navigateTo(`/servers/${guildId}/channels/${channels[0].uuid}`, { replace: true });
}
})

View file

@ -14,6 +14,8 @@
"@nuxt/icon": "1.13.0", "@nuxt/icon": "1.13.0",
"@nuxt/image": "1.10.0", "@nuxt/image": "1.10.0",
"@pinia/nuxt": "0.11.0", "@pinia/nuxt": "0.11.0",
"dompurify": "^3.2.6",
"marked": "^15.0.12",
"nuxt": "^3.17.0", "nuxt": "^3.17.0",
"pinia": "^3.0.2", "pinia": "^3.0.2",
"pinia-plugin-persistedstate": "^4.2.0", "pinia-plugin-persistedstate": "^4.2.0",

View file

@ -43,6 +43,7 @@ const registrationEnabled = ref<boolean>(true);
const apiBase = useCookie("api_base"); const apiBase = useCookie("api_base");
if (apiBase.value) { if (apiBase.value) {
console.log("apiBase:", apiBase.value);
const statsUrl = new URL("/stats", apiBase.value).href; const statsUrl = new URL("/stats", apiBase.value).href;
const { status, data } = await useFetch<StatsResponse>(statsUrl); const { status, data } = await useFetch<StatsResponse>(statsUrl);
if (status.value == "success" && data.value) { if (status.value == "success" && data.value) {
@ -62,9 +63,9 @@ async function formLogin(e: Event) {
console.log("logged in"); console.log("logged in");
if (query.redirect_to) { if (query.redirect_to) {
console.log("redirecting to:", query.redirect_to); console.log("redirecting to:", query.redirect_to);
return await navigateTo(query.redirect_to); return await navigateTo(query.redirect_to, { replace: true });
} }
return await navigateTo("/"); return await navigateTo("/", { replace: true });
} catch (error) { } catch (error) {
console.error("Error logging in:", error); console.error("Error logging in:", error);
} }

View file

@ -47,14 +47,17 @@ definePageMeta({
layout: "auth" layout: "auth"
}) })
const instanceUrl = useCookie("instance_url").value; const registrationEnabled = useState("registrationEnabled", () => true);
const registrationEnabled = ref<boolean>(false);
if (instanceUrl) { console.log("wah");
const statsUrl = new URL("/stats", instanceUrl).href; console.log("weoooo")
const { status, data, error } = await useFetch<StatsResponse>(statsUrl); const apiBase = useCookie("api_base");
console.log("apiBase:", apiBase.value);
if (apiBase.value) {
const { status, data, error } = await useFetch<StatsResponse>(`${apiBase.value}/stats`);
if (status.value == "success" && data.value) { if (status.value == "success" && data.value) {
registrationEnabled.value = data.value.registration_enabled; registrationEnabled.value = data.value.registration_enabled;
console.log("set registration enabled value to:", data.value.registration_enabled);
} }
} }
@ -92,12 +95,6 @@ const query = useRoute().query as Record<string, string>;
const searchParams = new URLSearchParams(query); const searchParams = new URLSearchParams(query);
const loginUrl = `/login?${searchParams}` const loginUrl = `/login?${searchParams}`
onMounted(() => {
if (auth.accessToken.value) {
//return navigateTo(redirectTo ? redirectTo as string : useAppConfig().baseURL as string);
}
});
/* /*
watch(() => form.username, (newValue) => { watch(() => form.username, (newValue) => {
console.log("username change:", newValue); console.log("username change:", newValue);

View file

@ -5,7 +5,7 @@
<h3> <h3>
{{ server?.name }} {{ server?.name }}
<span> <span>
<button @click="showServerSettings"> <button @click="showGuildSettings">
<Icon name="lucide:settings" /> <Icon name="lucide:settings" />
</button> </button>
</span> </span>
@ -20,15 +20,17 @@
<div id="channels-list"> <div id="channels-list">
<Channel v-for="channel of channels" :name="channel.name" <Channel v-for="channel of channels" :name="channel.name"
:uuid="channel.uuid" :current-uuid="(route.params.channelId as string)" :uuid="channel.uuid" :current-uuid="(route.params.channelId as string)"
:href="`/guilds/${route.params.serverId}/channels/${channel.uuid}`" /> :href="`/servers/${route.params.serverId}/channels/${channel.uuid}`" />
</div> </div>
</div> </div>
<MessageArea :channel-url="channelUrlPath" /> <MessageArea :channel-url="channelUrlPath" />
<div id="members-container">
<div id="members-list"> <div id="members-list">
<div class="member-item" v-for="member of members"> <div class="member-item" v-for="member of members" tabindex="0">
<img v-if="member.avatar" :src="member.avatar" :alt="member.displayName" height="30" /> <img v-if="member.user.avatar" class="member-avatar" :src="member.user.avatar" :alt="member.user.display_name ?? member.user.username" />
<Icon v-else name="lucide:user" size="30" /> <Icon v-else class="member-avatar" name="lucide:user" />
<span class="member-display-name">{{ member.displayName }}</span> <span class="member-display-name">{{ member.user.display_name ?? member.user.username }}</span>
</div>
</div> </div>
</div> </div>
</NuxtLayout> </NuxtLayout>
@ -40,7 +42,7 @@ const route = useRoute();
const loading = useState("loading"); const loading = useState("loading");
const channelUrlPath = `/channels/${route.params.channelId}`; const channelUrlPath = `channels/${route.params.channelId}`;
const server = ref<GuildResponse | undefined>(); const server = ref<GuildResponse | undefined>();
const channels = ref<ChannelResponse[] | undefined>(); const channels = ref<ChannelResponse[] | undefined>();
@ -52,68 +54,25 @@ import type { ChannelResponse, GuildResponse, MessageResponse } from "~/types/in
//const servers = await fetchWithApi("/servers") as { uuid: string, name: string, description: string }[]; //const servers = await fetchWithApi("/servers") as { uuid: string, name: string, description: string }[];
//console.log("channelid: servers:", servers); //console.log("channelid: servers:", servers);
const members = [
{ const { fetchMembers } = useApi();
id: "3287484395", const members = await fetchMembers(route.params.serverId as string);
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: ""
}
];
onMounted(async () => { onMounted(async () => {
console.log("channelid: set loading to true"); console.log("channelid: set loading to true");
server.value = await fetchWithApi(`servers/${route.params.serverId}`); const guildUrl = `guilds/${route.params.serverId}`;
server.value = await fetchWithApi(guildUrl);
channels.value = await fetchWithApi(`/channels`); channels.value = await fetchWithApi(`${guildUrl}/channels`);
console.log("channels:", channels.value); console.log("channels:", channels.value);
channel.value = await fetchWithApi(route.path); channel.value = await fetchWithApi(`/channels/${route.params.channelId}`);
console.log("channel:", channel.value); console.log("channel:", channel.value);
console.log("channelid: channel:", channel); console.log("channelid: channel:", channel);
console.log("channelid: set loading to false"); console.log("channelid: set loading to false");
}); });
function showServerSettings() { } function showGuildSettings() { }
function toggleInvitePopup(e: Event) { function toggleInvitePopup(e: Event) {
e.preventDefault(); e.preventDefault();
@ -122,17 +81,6 @@ function toggleInvitePopup(e: Event) {
</script> </script>
<style> <style>
.member-item {
display: flex;
justify-content: center;
align-items: center;
margin-top: .5em;
margin-bottom: .5em;
}
#members-list {
padding-top: 3dvh;
}
#middle-left-column { #middle-left-column {
padding-left: 1dvw; padding-left: 1dvw;
@ -140,16 +88,48 @@ function toggleInvitePopup(e: Event) {
border-right: 1px solid rgb(70, 70, 70); border-right: 1px solid rgb(70, 70, 70);
} }
#members-list { #members-container {
padding-top: 1dvh;
padding-left: 1dvw; padding-left: 1dvw;
padding-right: 1dvw; padding-right: 1dvw;
border-left: 1px solid rgb(70, 70, 70); border-left: 1px solid rgb(70, 70, 70);
} }
#members-list {
display: flex;
flex-direction: column;
overflow-y: scroll;
padding-left: 1dvw;
padding-right: 1dvw;
margin-top: 1dvh;
}
.member-item {
display: grid;
grid-template-columns: 2dvw 1fr;
margin-top: .5em;
margin-bottom: .5em;
gap: 1em;
align-items: center;
text-align: left;
}
#channels-list { #channels-list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 1dvh; gap: 1dvh;
} }
.member-avatar {
height: 2.3em;
width: 2.3em;
border-radius: 50%;
}
.member-display-name {
overflow: hidden;
text-overflow: ellipsis;
}
</style> </style>

View file

@ -5,8 +5,9 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
const server = await fetchWithApi(`/guilds/${useRoute().params.serverId}`); definePageMeta({
console.log("server:", server); middleware: "server"
});
</script> </script>

159
pages/settings.vue Normal file
View file

@ -0,0 +1,159 @@
<template>
<div id="settings-page-container">
<div id="settings-page">
<div id="sidebar">
<h4>(Search bar here)</h4>
<ul>
<div v-for="category in categories" :key="category.displayName">
<h2>{{ category.displayName }}</h2>
<li v-for="page in category.pages" :key="page.displayName" @click="selectCategory(page)"
:class="{ 'sidebar-focus': selectedPage === page.displayName }">
{{ page.displayName }}
</li>
<span class="spacer"></span>
</div>
<Button text="Log Out" :callback=logout variant="scary"></Button>
</ul>
</div>
<div id="sub-page">
<component :is="currentPage.pageData" />
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import Button from '~/components/Button.vue';
const { logout } = useAuth()
interface Page {
displayName: string;
pageData: any; // is actually Component but TS is yelling at me :(
}
interface Category {
displayName: string;
pages: Page[];
}
import Account from '~/components/Settings/UserSettings/Account.vue';
import Privacy from '~/components/Settings/UserSettings/Privacy.vue';
import Devices from '~/components/Settings/UserSettings/Devices.vue';
import Connections from '~/components/Settings/UserSettings/Connections.vue';
import Appearance from '~/components/Settings/AppSettings/Appearance.vue';
import Notifications from '~/components/Settings/AppSettings/Notifications.vue';
import Keybinds from '~/components/Settings/AppSettings/Keybinds.vue';
import Language from '~/components/Settings/AppSettings/Language.vue';
const settingsCategories = {
userSettings: {
displayName: "User Settings",
pages: [
{ displayName: "My Account", pageData: Account },
{ displayName: "Privacy", pageData: Privacy },
{ displayName: "Devices", pageData: Devices },
{ displayName: "Connections", pageData: Connections },
]
},
appSettings: {
displayName: "App Settings",
pages: [
{ displayName: "Appearance", pageData: Appearance },
{ displayName: "Notifications", pageData: Notifications },
{ displayName: "Keybinds", pageData: Keybinds },
{ displayName: "Language", pageData: Language },
]
},
};
const categories = Object.values(settingsCategories);
let currentPage = ref(categories[0].pages[0]);
let selectedPage = ref(currentPage.value.displayName); // used to highlight the current channel
function selectCategory(page: Page) {
currentPage.value = page;
selectedPage.value = page.displayName;
};
</script>
<style scoped>
#settings-page-container {
height: 100%;
align-content: center;
overflow-y: hidden;
margin: 0;
}
#settings-page {
height: 100vh;
display: flex;
}
#sidebar {
min-width: 25dvw;
max-width: 25dvw;
background-color: #2f3136;
color: white;
padding: 1dvh 1dvw;
margin-left: auto;
overflow-y: auto;
height: 100vh;
}
#sidebar h2 {
font-size: 0.95em;
padding: 0 0.8dvw;
}
#sidebar ul {
list-style-type: none;
padding: 0;
margin: 0;
}
#sidebar li {
border-radius: 8px;
padding: 0.8dvh 0.8dvw;
font-size: 1.4em;
cursor: pointer;
transition: background-color 0.3s;
}
.sidebar-focus {
background-color: #383B41;
}
#sidebar li:hover {
background-color: #40444b;
}
#sub-page {
flex-grow: 1;
min-width: 70dvw;
max-width: 70dvw;
padding-left: 1.5rem;
margin-right: auto;
overflow-y: auto;
height: 100vh;
}
.spacer {
height: 0.2dvh;
display: block;
margin: 0.8dvh 1dvw;
background-color: #2c2e32;
}
/* applies to child pages too */
:deep(h5) {
color: red;
}
</style>

26
pnpm-lock.yaml generated
View file

@ -20,6 +20,12 @@ importers:
'@pinia/nuxt': '@pinia/nuxt':
specifier: 0.11.0 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))) 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: nuxt:
specifier: ^3.17.0 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) 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)
@ -1199,6 +1205,9 @@ packages:
'@types/triple-beam@1.3.5': '@types/triple-beam@1.3.5':
resolution: {integrity: sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==} resolution: {integrity: sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==}
'@types/trusted-types@2.0.7':
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
'@types/yauzl@2.10.3': '@types/yauzl@2.10.3':
resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==}
@ -2113,6 +2122,9 @@ packages:
resolution: {integrity: sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==} resolution: {integrity: sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==}
engines: {node: '>= 4'} engines: {node: '>= 4'}
dompurify@3.2.6:
resolution: {integrity: sha512-/2GogDQlohXPZe6D6NOgQvXLPSYBqIWMnZ8zzOhn09REE4eyAzb+Hed3jhoM9OkuaJ8P6ZGTTVWQKAi8ieIzfQ==}
domutils@3.2.2: domutils@3.2.2:
resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==} resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==}
@ -3092,6 +3104,11 @@ packages:
resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==}
engines: {node: '>=8'} engines: {node: '>=8'}
marked@15.0.12:
resolution: {integrity: sha512-8dD6FusOQSrpv9Z1rdNMdlSgQOIP880DHqnohobOmYLElGEqAL/JvxvuxZO16r4HtjTlfPRDC1hbvxC9dPN2nA==}
engines: {node: '>= 18'}
hasBin: true
math-intrinsics@1.1.0: math-intrinsics@1.1.0:
resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
engines: {node: '>= 0.4'} engines: {node: '>= 0.4'}
@ -6094,6 +6111,9 @@ snapshots:
'@types/triple-beam@1.3.5': {} '@types/triple-beam@1.3.5': {}
'@types/trusted-types@2.0.7':
optional: true
'@types/yauzl@2.10.3': '@types/yauzl@2.10.3':
dependencies: dependencies:
'@types/node': 22.15.3 '@types/node': 22.15.3
@ -7082,6 +7102,10 @@ snapshots:
dependencies: dependencies:
domelementtype: 2.3.0 domelementtype: 2.3.0
dompurify@3.2.6:
optionalDependencies:
'@types/trusted-types': 2.0.7
domutils@3.2.2: domutils@3.2.2:
dependencies: dependencies:
dom-serializer: 2.0.0 dom-serializer: 2.0.0
@ -8170,6 +8194,8 @@ snapshots:
dependencies: dependencies:
semver: 6.3.1 semver: 6.3.1
marked@15.0.12: {}
math-intrinsics@1.1.0: {} math-intrinsics@1.1.0: {}
mdn-data@2.0.28: {} mdn-data@2.0.28: {}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before After
Before After

View file

@ -23,6 +23,14 @@ export interface GuildResponse {
member_count: number member_count: number
} }
export interface GuildMemberResponse {
uuid: string,
nickname: string,
user_uuid: string,
guild_uuid: string,
user: UserResponse
}
export interface ChannelResponse { export interface ChannelResponse {
uuid: string, uuid: string,
guild_uuid: string, guild_uuid: string,
@ -50,6 +58,8 @@ export interface UserResponse {
username: string, username: string,
display_name: string | null, display_name: string | null,
avatar: string | null, avatar: string | null,
pronouns: string | null,
about: string | null,
email?: string, email?: string,
email_verified?: boolean email_verified?: boolean
} }
@ -62,3 +72,14 @@ export interface StatsResponse {
email_verification_required: boolean, email_verification_required: boolean,
build_number: string build_number: string
} }
export interface ScrollPosition {
scrollHeight: number,
scrollWidth: number,
scrollTop: number,
scrollLeft: number
offsetHeight: number,
offsetWidth: number,
offsetTop: number,
offsetLeft: number
}

View file

@ -1,6 +0,0 @@
import type { UserResponse } from "~/types/interfaces"
export default async (serverId: string, memberId: string): Promise<UserResponse> => {
const user = await fetchWithApi(`/guilds/${serverId}/members/${memberId}`) as UserResponse;
return user;
}

View file

@ -1,6 +0,0 @@
import type { UserResponse } from "~/types/interfaces"
export default async (serverId: string, userId: string): Promise<UserResponse> => {
const user = await fetchWithApi(`/users/${userId}`) as UserResponse;
return user;
}

View file

@ -9,8 +9,6 @@ export default async <T>(path: string, options: NitroFetchOptions<string> = {})
path = path.slice(0, path.lastIndexOf("/")); path = path.slice(0, path.lastIndexOf("/"));
} }
console.log("formatted path:", path); console.log("formatted path:", path);
const accessToken = useCookie("access_token");
console.log("access token:", accessToken.value);
const apiBase = useCookie("api_base").value; const apiBase = useCookie("api_base").value;
const apiVersion = useRuntimeConfig().public.apiVersion; const apiVersion = useRuntimeConfig().public.apiVersion;
console.log("heyoooo") console.log("heyoooo")
@ -21,10 +19,14 @@ export default async <T>(path: string, options: NitroFetchOptions<string> = {})
} }
console.log("path:", path) console.log("path:", path)
const { revoke, refresh } = useAuth(); const { revoke, refresh } = useAuth();
console.log("access token 2:", accessToken.value);
let headers: HeadersInit = {}; let headers: HeadersInit = {};
let reauthFailed = false;
while (!reauthFailed) {
const accessToken = useCookie("access_token");
console.log("access token:", accessToken.value);
if (accessToken.value) { if (accessToken.value) {
headers = { headers = {
...options.headers, ...options.headers,
@ -35,9 +37,6 @@ export default async <T>(path: string, options: NitroFetchOptions<string> = {})
...options.headers ...options.headers
}; };
} }
let reauthFailed = false;
while (!reauthFailed) {
try { try {
console.log("fetching:", URL.parse(apiBase + path)); console.log("fetching:", URL.parse(apiBase + path));
const res = await $fetch<T>(URL.parse(apiBase + path)!.href, { const res = await $fetch<T>(URL.parse(apiBase + path)!.href, {
@ -74,9 +73,10 @@ export default async <T>(path: string, options: NitroFetchOptions<string> = {})
console.log("Path is refresh endpoint, throwing error"); console.log("Path is refresh endpoint, throwing error");
throw error; throw error;
} }
} } else {
console.log("throwing error"); console.log("throwing error:", error);
throw error; throw error;
} }
} }
}
} }

View file

@ -0,0 +1,14 @@
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
};
}

View file

@ -1,6 +1,6 @@
export default (element: Ref<HTMLElement | undefined, HTMLElement | undefined>) => { export default (element: HTMLElement) => {
if (element.value) { if (element) {
element.value.scrollTo({ top: element.value.scrollHeight }); element.scrollTo({ top: element.scrollHeight });
return; return;
} }
} }

View file

@ -0,0 +1,5 @@
import type { ScrollPosition } from "~/types/interfaces";
export default (element: HTMLElement, scrollPosition: ScrollPosition) => {
return element.scrollTo({ top: scrollPosition.scrollTop, left: scrollPosition.scrollLeft });
}