Compare commits
102 commits
device-lis
...
main
Author | SHA1 | Date | |
---|---|---|---|
8be948623b | |||
82e0e59617 | |||
b07a0aa5a0 | |||
eb2af0f7ec | |||
ddf173ee8b | |||
6a65b257e0 | |||
c87fffe6c9 | |||
08436fdce0 | |||
c93a1829f8 | |||
72701c9aef | |||
3a65cfd10a | |||
ad7a6b5bb6 | |||
49e8c34254 | |||
232aec13a5 | |||
771c0699a7 | |||
4d5cd86ec3 | |||
3953a754bd | |||
60e7a42f92 | |||
89d0023c07 | |||
118f098b46 | |||
317ec4bcd6 | |||
315258a8d5 | |||
8ffe3aa738 | |||
8d53b2765f | |||
4b1db5961a | |||
80df3dd13d | |||
883ec0354d | |||
808cc980a7 | |||
0697e60ab9 | |||
b6970ffc1c | |||
eabe3b3704 | |||
c295225c43 | |||
f1e07bd43c | |||
5f2267a448 | |||
52af245fdf | |||
688001a482 | |||
f26c5fd7ce | |||
5bd307451d | |||
db2a99736a | |||
0c4d42f3c1 | |||
f2fcdbf733 | |||
d5b7669291 | |||
f6ede67c26 | |||
4229682d69 | |||
cbe50dd028 | |||
100d5e80eb | |||
ea1f032ffc | |||
56ccd61107 | |||
ce5d65e62d | |||
ab87fb681c | |||
ace66980bf | |||
0f583f085e | |||
2ce09e7c7a | |||
73606b6bc3 | |||
8a172db3f4 | |||
e87edbc967 | |||
788222967b | |||
bca209ef81 | |||
b642deb087 | |||
2381960277 | |||
29243aa86f | |||
6d51fa5889 | |||
97bc6c45a9 | |||
ccd37a2fc3 | |||
68cb7438ce | |||
07fa883a14 | |||
4ce89d9803 | |||
32910d2077 | |||
63dbfa2a0d | |||
64131e6f9c | |||
186d3c7a0a | |||
a146eb001a | |||
17791fc017 | |||
42ed743054 | |||
491e736422 | |||
26243a8cd6 | |||
890c479f2c | |||
b81cd2b73a | |||
dfec4c9200 | |||
cbc010943c | |||
e7558d9a95 | |||
f98e8c6110 | |||
f4ddcf9d8d | |||
b319a06749 | |||
25cd9a397e | |||
bbc822604f | |||
9bfe3310cc | |||
06de4777f9 | |||
df741ee5d4 | |||
dac473e9fb | |||
fc87bd4b6f | |||
9d1eeff582 | |||
9f914de77b | |||
015b23f4e5 | |||
b6b8d10d29 | |||
480c91d419 | |||
088c6c558b | |||
7f1b26a59c | |||
047fe5e833 | |||
dc786cd420 | |||
9b7de48c02 | |||
be5d65883b |
60 changed files with 1139 additions and 366 deletions
|
@ -8,7 +8,6 @@ steps:
|
||||||
- pnpm build
|
- pnpm build
|
||||||
when:
|
when:
|
||||||
- event: push
|
- event: push
|
||||||
- event: pull_request
|
|
||||||
|
|
||||||
- name: container-build-and-publish
|
- name: container-build-and-publish
|
||||||
image: docker
|
image: docker
|
||||||
|
@ -23,3 +22,17 @@ steps:
|
||||||
when:
|
when:
|
||||||
- branch: main
|
- branch: main
|
||||||
event: push
|
event: push
|
||||||
|
|
||||||
|
- name: container-build-and-publish (staging)
|
||||||
|
image: docker
|
||||||
|
commands:
|
||||||
|
- docker login --username radical --password $PASSWORD git.gorb.app
|
||||||
|
- docker buildx build --platform linux/amd64,linux/arm64 --rm --push -t git.gorb.app/gorb/frontend:staging .
|
||||||
|
environment:
|
||||||
|
PASSWORD:
|
||||||
|
from_secret: docker_password
|
||||||
|
volumes:
|
||||||
|
- /var/run/podman/podman.sock:/var/run/docker.sock
|
||||||
|
when:
|
||||||
|
- branch: staging
|
||||||
|
event: push
|
||||||
|
|
30
app.vue
30
app.vue
|
@ -1,19 +1,21 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<Banner v-if="banner" />
|
<Banner v-if="banner" />
|
||||||
<NuxtPage :keepalive="true" />
|
<NuxtPage :keepalive="true" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import ContextMenu from '~/components/UserInterface/ContextMenu.vue';
|
import loadPreferredTheme from '~/utils/loadPreferredTheme';
|
||||||
import { render } from 'vue';
|
|
||||||
|
|
||||||
const banner = useState("banner", () => false);
|
const banner = useState("banner", () => false);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
loadPreferredTheme()
|
||||||
|
|
||||||
document.removeEventListener("contextmenu", contextMenuHandler);
|
document.removeEventListener("contextmenu", contextMenuHandler);
|
||||||
document.addEventListener("contextmenu", (e) => {
|
document.addEventListener("contextmenu", (e) => {
|
||||||
|
if (e.target instanceof Element && e.target.classList.contains("default-contextmenu")) return;
|
||||||
contextMenuHandler(e);
|
contextMenuHandler(e);
|
||||||
});
|
});
|
||||||
document.addEventListener("mousedown", (e) => {
|
document.addEventListener("mousedown", (e) => {
|
||||||
|
@ -50,21 +52,15 @@ function contextMenuHandler(e: MouseEvent) {
|
||||||
//]);
|
//]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentTheme = settingsLoad().selectedThemeId ?? "dark"
|
|
||||||
const baseURL = useRuntimeConfig().app.baseURL;
|
|
||||||
|
|
||||||
useHead({
|
|
||||||
link: [{
|
|
||||||
rel: "stylesheet",
|
|
||||||
href: `${baseURL}themes/${currentTheme}.css`
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
html,
|
html {
|
||||||
|
background-color: #1f1e1d;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: Arial, Helvetica, sans-serif;
|
font-family: var(--preferred-font), Arial, Helvetica, sans-serif;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
background: var(--optional-body-background);
|
background: var(--optional-body-background);
|
||||||
|
|
44
components/Avatar.vue
Normal file
44
components/Avatar.vue
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<template>
|
||||||
|
<NuxtImg v-if="displayAvatar"
|
||||||
|
class="display-avatar"
|
||||||
|
:src="displayAvatar"
|
||||||
|
:alt="displayName" />
|
||||||
|
<Icon v-else
|
||||||
|
name="lucide:user"
|
||||||
|
:alt="displayName" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { NuxtImg } from '#components';
|
||||||
|
import type { GuildMemberResponse, UserResponse } from '~/types/interfaces';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
user?: UserResponse,
|
||||||
|
member?: GuildMemberResponse,
|
||||||
|
}>();
|
||||||
|
|
||||||
|
|
||||||
|
let displayName: string
|
||||||
|
let displayAvatar: string | null
|
||||||
|
|
||||||
|
const user = props.user || props.member?.user
|
||||||
|
|
||||||
|
if (user) {
|
||||||
|
displayName = getDisplayName(user, props.member)
|
||||||
|
|
||||||
|
if (user.avatar) {
|
||||||
|
displayAvatar = user.avatar
|
||||||
|
} else if (!isCanvasBlocked()){
|
||||||
|
displayAvatar = generateDefaultIcon(displayName, user.uuid)
|
||||||
|
} else {
|
||||||
|
displayAvatar = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.display-avatar {
|
||||||
|
border-radius: var(--pfp-radius);
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,10 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="isCurrentChannel" class="channel-list-link-container rounded-corners current-channel" tabindex="0">
|
<div v-if="isCurrentChannel" class="channel-list-link-container rounded-corners current-channel" tabindex="0" :title="props.name">
|
||||||
<NuxtLink class="channel-list-link" :href="props.href" tabindex="-1">
|
<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" tabindex="0">
|
<div v-else class="channel-list-link-container rounded-corners" tabindex="0" :title="props.name">
|
||||||
<NuxtLink class="channel-list-link" :href="props.href" tabindex="-1">
|
<NuxtLink class="channel-list-link" :href="props.href" tabindex="-1">
|
||||||
# {{ props.name }}
|
# {{ props.name }}
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
|
@ -25,6 +25,8 @@ const isCurrentChannel = props.uuid == props.currentUuid;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
padding-left: .25em;
|
padding-left: .25em;
|
||||||
padding-right: .25em;
|
padding-right: .25em;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.channel-list-link-container {
|
.channel-list-link-container {
|
||||||
|
|
|
@ -4,23 +4,20 @@
|
||||||
<button class="guild-option-button" @click="setting.action" tabindex="0">{{ setting.name }}</button>
|
<button class="guild-option-button" @click="setting.action" tabindex="0">{{ setting.name }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<ModalInvite v-if="showInviteModal" :guild-id="guildId" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { render } from 'vue';
|
|
||||||
import InviteModal from '../Modals/InviteModal.vue';
|
|
||||||
|
|
||||||
const settings = [
|
const settings = [
|
||||||
{ name: "Invite", icon: "lucide:letter", action: openInviteModal }
|
{ name: "Invite", icon: "lucide:letter", action: openInviteModal }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const guildId = useRoute().params.serverId as string;
|
||||||
|
const showInviteModal = ref(false);
|
||||||
|
|
||||||
function openInviteModal() {
|
function openInviteModal() {
|
||||||
const div = document.createElement("div");
|
showInviteModal.value = true;
|
||||||
const guildId = useRoute().params.serverId as string;
|
|
||||||
console.log("guild id:", guildId);
|
|
||||||
const inviteModal = h(InviteModal, { guildId });
|
|
||||||
document.body.appendChild(div);
|
|
||||||
render(inviteModal, div);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="member-item" @click="togglePopup" @blur="hidePopup" tabindex="0">
|
<div class="member-item" @click="togglePopup" @blur="hidePopup" tabindex="0">
|
||||||
<img v-if="props.member.user.avatar" class="member-avatar" :src="props.member.user.avatar" :alt="props.member.user.display_name ?? props.member.user.username" />
|
<Avatar :member="props.member" class="member-avatar"/>
|
||||||
<Icon v-else class="member-avatar" name="lucide:user" />
|
<span class="member-display-name">{{ getDisplayName(props.member.user, props.member) }}</span>
|
||||||
<span class="member-display-name">{{ props.member.user.display_name || props.member.user.username }}</span>
|
|
||||||
<UserPopup v-if="isPopupVisible" :user="props.member.user" id="profile-popup" />
|
<UserPopup v-if="isPopupVisible" :user="props.member.user" id="profile-popup" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
|
@ -1,27 +1,30 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="middle-left-column">
|
<ResizableSidebar width="14rem" min-width="8rem" max-width="30rem" border-sides="right" local-storage-name="middleLeftColumn">
|
||||||
<div id="friend-sidebar">
|
<div id="middle-left-column">
|
||||||
<div>
|
<div id="friend-sidebar">
|
||||||
<h3>Direct Messages</h3>
|
<div>
|
||||||
</div>
|
<h3>Direct Messages</h3>
|
||||||
<VerticalSpacer />
|
</div>
|
||||||
|
<VerticalSpacer />
|
||||||
<NuxtLink class="user-item" :href="`/me/friends`" tabindex="0">
|
|
||||||
<Icon class="user-avatar" name="lucide:user" />
|
<NuxtLink class="user-item" :href="`/me`" tabindex="0">
|
||||||
<span class="user-display-name">Friends</span>
|
<Icon class="user-avatar" name="lucide:user" />
|
||||||
</NuxtLink>
|
<span class="user-display-name">Friends</span>
|
||||||
<VerticalSpacer />
|
</NuxtLink>
|
||||||
|
<VerticalSpacer />
|
||||||
<div id="direct-message-list">
|
|
||||||
<UserEntry v-for="user of friends" :user="user" :name="user.display_name || user.username"
|
<div id="direct-message-list">
|
||||||
:href="`/me/${user.uuid}`"/>
|
<UserEntry v-for="user of friends" :user="user"
|
||||||
|
:href="`/me/${user.uuid}`"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</ResizableSidebar>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import VerticalSpacer from '~/components/UserInterface/VerticalSpacer.vue';
|
import VerticalSpacer from '~/components/UserInterface/VerticalSpacer.vue';
|
||||||
|
import ResizableSidebar from '../UserInterface/ResizableSidebar.vue';
|
||||||
|
|
||||||
const { fetchFriends } = useApi();
|
const { fetchFriends } = useApi();
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<UserEntry v-for="user of friends" :user="user" :name="user.display_name || user.username"
|
<UserEntry v-for="user of friends" :user="user" :name="getDisplayName(user)"
|
||||||
:href="`/me/${user.uuid}`"/>
|
:href="`/me/${user.uuid}`"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
const { fetchFriends } = useApi();
|
const { fetchFriends } = useApi();
|
||||||
|
|
||||||
const friends = await fetchFriends()
|
const friends = sortUsers(await fetchFriends())
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
variant: string
|
variant: string
|
||||||
|
|
|
@ -4,22 +4,14 @@
|
||||||
:editing.sync="props.editing" :replying-to.sync="props.replyingTo">
|
:editing.sync="props.editing" :replying-to.sync="props.replyingTo">
|
||||||
<div v-if="props.replyMessage" class="message-reply-svg">
|
<div v-if="props.replyMessage" class="message-reply-svg">
|
||||||
<svg
|
<svg
|
||||||
width="1.5em"
|
width="1.5em" height="1.5em"
|
||||||
height="1.5em"
|
viewBox="0 0 150 87.5" version="1.1" id="svg1"
|
||||||
viewBox="0 0 151.14355 87.562065"
|
|
||||||
version="1.1"
|
|
||||||
id="svg1"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
style="overflow: visible;">
|
style="overflow: visible;">
|
||||||
<defs
|
<defs id="defs1" />
|
||||||
id="defs1" />
|
<g id="layer1"
|
||||||
<g
|
|
||||||
id="layer1"
|
|
||||||
transform="translate(40,-35)">
|
transform="translate(40,-35)">
|
||||||
<g
|
<g id="g3"
|
||||||
id="g3"
|
transform="translate(-35,-20)">
|
||||||
transform="translate(-35,-20)">
|
|
||||||
<path
|
<path
|
||||||
style="stroke:var(--reply-text-color);stroke-width:8;stroke-opacity:1"
|
style="stroke:var(--reply-text-color);stroke-width:8;stroke-opacity:1"
|
||||||
d="m 120.02168,87.850978 100.76157,2.4e-5"
|
d="m 120.02168,87.850978 100.76157,2.4e-5"
|
||||||
|
@ -32,16 +24,17 @@
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<MessageReply v-if="props.replyMessage" :author="props.replyMessage.user.display_name || props.replyMessage.user.username" :text="props.replyMessage?.message"
|
<MessageReply v-if="props.replyMessage" :id="props.message.uuid"
|
||||||
:id="props.message.uuid" :reply-id="props.replyMessage.uuid" max-width="reply" />
|
:author="getDisplayName(props.replyMessage.user)"
|
||||||
|
:text="props.replyMessage?.message"
|
||||||
|
:reply-id="props.replyMessage.uuid" max-width="reply" />
|
||||||
<div class="left-column">
|
<div class="left-column">
|
||||||
<img v-if="props.img" class="message-author-avatar" :src="props.img" :alt="author?.display_name || author?.username" />
|
<Avatar :user="props.author" 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" tabindex="0">
|
<span class="message-author-username" tabindex="0" :style="`color: ${props.authorColor}`">
|
||||||
{{ author?.display_name || author?.username }}
|
{{ getDisplayName(props.author) }}
|
||||||
</span>
|
</span>
|
||||||
<span class="message-date" :title="date.toString()">
|
<span class="message-date" :title="date.toString()">
|
||||||
<span v-if="getDayDifference(date, currentDate) === 1">Yesterday at</span>
|
<span v-if="getDayDifference(date, currentDate) === 1">Yesterday at</span>
|
||||||
|
@ -50,8 +43,9 @@
|
||||||
{{ date.toLocaleTimeString(undefined, { hour12: props.format == "12", timeStyle: "short" }) }}
|
{{ date.toLocaleTimeString(undefined, { hour12: props.format == "12", timeStyle: "short" }) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="message-text" v-html="sanitized" tabindex="0"></div>
|
<div class="message-text" v-html="sanitized" :hidden="hasEmbed" tabindex="0"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<MessageMedia v-if="mediaLinks.length" :links="mediaLinks" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else ref="messageElement" @contextmenu="createContextMenu($event, menuItems)" :id="props.last ? 'last-message' : undefined"
|
<div v-else ref="messageElement" @contextmenu="createContextMenu($event, menuItems)" :id="props.last ? 'last-message' : undefined"
|
||||||
class="message grouped-message" :class="{ 'message-margin-bottom': props.marginBottom, 'mentioned': props.replyMessage || props.isMentioned }"
|
class="message grouped-message" :class="{ 'message-margin-bottom': props.marginBottom, 'mentioned': props.replyMessage || props.isMentioned }"
|
||||||
|
@ -62,8 +56,9 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="message-data">
|
<div class="message-data">
|
||||||
<div class="message-text" :class="$style['message-text']" v-html="sanitized" tabindex="0"></div>
|
<div class="message-text" :class="$style['message-text']" v-html="sanitized" :hidden="hasEmbed" tabindex="0"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<MessageMedia v-if="mediaLinks.length" :links="mediaLinks" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -71,6 +66,8 @@
|
||||||
import DOMPurify from 'dompurify';
|
import DOMPurify from 'dompurify';
|
||||||
import { parse } from 'marked';
|
import { parse } from 'marked';
|
||||||
import type { MessageProps } from '~/types/props';
|
import type { MessageProps } from '~/types/props';
|
||||||
|
import MessageMedia from './MessageMedia.vue';
|
||||||
|
import MessageReply from './UserInterface/MessageReply.vue';
|
||||||
|
|
||||||
const props = defineProps<MessageProps>();
|
const props = defineProps<MessageProps>();
|
||||||
|
|
||||||
|
@ -85,6 +82,13 @@ console.log("[MSG] message to render:", props.message);
|
||||||
console.log("author:", props.author);
|
console.log("author:", props.author);
|
||||||
console.log("[MSG] reply message:", props.replyMessage);
|
console.log("[MSG] reply message:", props.replyMessage);
|
||||||
|
|
||||||
|
const linkRegex = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g;
|
||||||
|
const linkMatches = props.message.message.matchAll(linkRegex).map(link => link[0]);
|
||||||
|
const mediaLinks: string[] = [];
|
||||||
|
console.log("link matches:", linkMatches);
|
||||||
|
|
||||||
|
const hasEmbed = ref(false);
|
||||||
|
|
||||||
const sanitized = ref<string>();
|
const sanitized = ref<string>();
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
@ -97,7 +101,7 @@ onMounted(async () => {
|
||||||
],
|
],
|
||||||
ALLOW_DATA_ATTR: false,
|
ALLOW_DATA_ATTR: false,
|
||||||
ALLOW_SELF_CLOSE_IN_ATTR: false,
|
ALLOW_SELF_CLOSE_IN_ATTR: false,
|
||||||
ALLOWED_ATTR: []
|
ALLOWED_ATTR: ["href"]
|
||||||
});
|
});
|
||||||
console.log("adding listeners")
|
console.log("adding listeners")
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
@ -111,6 +115,27 @@ onMounted(async () => {
|
||||||
});
|
});
|
||||||
console.log("added listeners");
|
console.log("added listeners");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const link of linkMatches) {
|
||||||
|
console.log("link:", link);
|
||||||
|
try {
|
||||||
|
const res = await $fetch.raw(link);
|
||||||
|
if (res.ok && res.headers.get("content-type")?.match(/^image\/(apng|gif|jpeg|png|webp)$/)) {
|
||||||
|
console.log("link is image");
|
||||||
|
mediaLinks.push(link);
|
||||||
|
}
|
||||||
|
if (mediaLinks.length) {
|
||||||
|
hasEmbed.value = true
|
||||||
|
setTimeout(() => {
|
||||||
|
scrollToBottom(document.getElementById("messages") as HTMLDivElement);
|
||||||
|
}, 500);
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("media links:", mediaLinks);
|
||||||
});
|
});
|
||||||
|
|
||||||
//function toggleTooltip(e: Event) {
|
//function toggleTooltip(e: Event) {
|
||||||
|
@ -196,7 +221,6 @@ function getDayDifference(date1: Date, date2: Date) {
|
||||||
|
|
||||||
.message-author-avatar {
|
.message-author-avatar {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-radius: 50%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-column {
|
.left-column {
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="message-area">
|
<div id="message-area">
|
||||||
<div id="messages" ref="messagesElement">
|
<div id="messages" ref="messagesElement">
|
||||||
<Message v-for="(message, i) of messages" :username="message.user.display_name ?? message.user.username"
|
<Message v-for="(message, i) of messages" :username="getDisplayName(message.user)"
|
||||||
:text="message.message" :timestamp="messageTimestamps[message.uuid]" :img="message.user.avatar"
|
:text="message.message" :timestamp="messageTimestamps[message.uuid]" :img="message.user.avatar"
|
||||||
:format="timeFormat" :type="messagesType[message.uuid]"
|
:format="timeFormat" :type="messagesType[message.uuid]"
|
||||||
:margin-bottom="(messages[i + 1] && messagesType[messages[i + 1].uuid] == 'normal') ?? false"
|
:margin-bottom="(messages[i + 1] && messagesType[messages[i + 1].uuid] == 'normal') ?? false"
|
||||||
:last="i == messages.length - 1" :message-id="message.uuid" :author="message.user" :me="me"
|
:last="i == messages.length - 1" :message-id="message.uuid" :author="message.user" :me="me"
|
||||||
:message="message" :is-reply="message.reply_to"
|
:message="message" :is-reply="message.reply_to"
|
||||||
|
:author-color="`${generateIrcColor(message.user.uuid)}`"
|
||||||
:reply-message="message.reply_to ? getReplyMessage(message.reply_to) : undefined" />
|
:reply-message="message.reply_to ? getReplyMessage(message.reply_to) : undefined" />
|
||||||
</div>
|
</div>
|
||||||
<div id="message-box" class="rounded-corners">
|
<div id="message-box" class="rounded-corners">
|
||||||
|
@ -41,6 +42,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { MessageResponse, ScrollPosition, UserResponse } from '~/types/interfaces';
|
import type { MessageResponse, ScrollPosition, UserResponse } from '~/types/interfaces';
|
||||||
import scrollToBottom from '~/utils/scrollToBottom';
|
import scrollToBottom from '~/utils/scrollToBottom';
|
||||||
|
import { generateIrcColor } from '#imports';
|
||||||
|
|
||||||
const props = defineProps<{ channelUrl: string, amount?: number, offset?: number }>();
|
const props = defineProps<{ channelUrl: string, amount?: number, offset?: number }>();
|
||||||
|
|
||||||
|
@ -251,6 +253,8 @@ onMounted(async () => {
|
||||||
if (import.meta.server) return;
|
if (import.meta.server) return;
|
||||||
console.log("[MSG] messages keys:", Object.values(messages.value));
|
console.log("[MSG] messages keys:", Object.values(messages.value));
|
||||||
if (messagesElement.value) {
|
if (messagesElement.value) {
|
||||||
|
await nextTick();
|
||||||
|
await nextTick();
|
||||||
scrollToBottom(messagesElement.value);
|
scrollToBottom(messagesElement.value);
|
||||||
let fetched = false;
|
let fetched = false;
|
||||||
const amount = messages.value.length;
|
const amount = messages.value.length;
|
||||||
|
|
47
components/MessageMedia.vue
Normal file
47
components/MessageMedia.vue
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<template>
|
||||||
|
<div class="media-container">
|
||||||
|
<NuxtImg v-for="link of props.links" class="media-item" :src="link" @click.prevent="createModal(link)" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ModalBase } from '#components';
|
||||||
|
import { render } from 'vue';
|
||||||
|
|
||||||
|
|
||||||
|
const props = defineProps<{ links: string[] }>();
|
||||||
|
|
||||||
|
function createModal(link: string) {
|
||||||
|
const div = document.createElement("div");
|
||||||
|
const modal = h(ModalBase, {
|
||||||
|
obscure: true,
|
||||||
|
onClose: () => unrender(div),
|
||||||
|
onCancel: () => unrender(div),
|
||||||
|
},
|
||||||
|
[
|
||||||
|
h("img", {
|
||||||
|
src: link,
|
||||||
|
class: "default-contextmenu"
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
|
document.body.appendChild(div);
|
||||||
|
render(modal, div);
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
.media-container {
|
||||||
|
grid-column: 2;
|
||||||
|
grid-row: 3;
|
||||||
|
margin-left: .5dvw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.media-item {
|
||||||
|
cursor: pointer;
|
||||||
|
max-width: 15dvw;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<Modal v-bind="props" :title="props.title || 'Create an invite'">
|
<ModalBase v-bind="props" :title="props.title || 'Create an invite'">
|
||||||
<div v-if="invite" id="invite-body">
|
<div v-if="invite" id="invite-body">
|
||||||
<div id="invite-label">{{ invite }}</div>
|
<div id="invite-label">{{ invite }}</div>
|
||||||
<div id="invite-buttons">
|
<div id="invite-buttons">
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<Button text="Generate Invite" variant="normal" :callback="generateInvite">Generate Invite</Button>
|
<Button text="Generate Invite" variant="normal" :callback="generateInvite">Generate Invite</Button>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</ModalBase>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import Cropper from 'cropperjs';
|
import Cropper from 'cropperjs';
|
||||||
|
import Button from '../UserInterface/Button.vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
imageSrc: String,
|
imageSrc: String,
|
||||||
|
|
|
@ -32,13 +32,13 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import RadioButtons from '~/components/UserInterface/RadioButtons.vue';
|
import RadioButtons from '~/components/UserInterface/RadioButtons.vue';
|
||||||
import type { TimeFormat } from '~/types/settings';
|
import type { TimeFormat } from '~/types/settings';
|
||||||
|
import loadPreferredTheme from '~/utils/loadPreferredTheme';
|
||||||
import settingSave from '~/utils/settingSave';
|
import settingSave from '~/utils/settingSave';
|
||||||
|
|
||||||
const runtimeConfig = useRuntimeConfig()
|
const runtimeConfig = useRuntimeConfig()
|
||||||
const defaultThemes = runtimeConfig.public.defaultThemes
|
const defaultThemes = runtimeConfig.public.defaultThemes
|
||||||
const baseURL = runtimeConfig.app.baseURL;
|
const baseURL = runtimeConfig.app.baseURL;
|
||||||
const timeFormatTextStrings = ["Auto", "12-Hour", "24-Hour"]
|
const timeFormatTextStrings = ["Auto", "12-Hour", "24-Hour"]
|
||||||
let themeLinkElement: HTMLLinkElement | null = null;
|
|
||||||
|
|
||||||
const themes: Array<Theme> = []
|
const themes: Array<Theme> = []
|
||||||
|
|
||||||
|
@ -51,20 +51,8 @@ interface Theme {
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeTheme(id: string, url: string) {
|
function changeTheme(id: string, url: string) {
|
||||||
if (themeLinkElement && themeLinkElement.getAttribute('href') === `${baseURL}themes/${url}`) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
settingSave("selectedThemeId", id)
|
settingSave("selectedThemeId", id)
|
||||||
|
loadPreferredTheme()
|
||||||
// if the theme didn't originally load for some reason, create it
|
|
||||||
if (!themeLinkElement) {
|
|
||||||
themeLinkElement = document.createElement('link');
|
|
||||||
themeLinkElement.rel = 'stylesheet';
|
|
||||||
document.head.appendChild(themeLinkElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
themeLinkElement.href = `${baseURL}themes/${url}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchThemes() {
|
async function fetchThemes() {
|
||||||
|
|
11
components/Settings/AppSettings/index.ts
Normal file
11
components/Settings/AppSettings/index.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import Appearance from './Appearance.vue';
|
||||||
|
import Notifications from './Notifications.vue';
|
||||||
|
import Keybinds from './Keybinds.vue';
|
||||||
|
import Language from './Language.vue';
|
||||||
|
|
||||||
|
export {
|
||||||
|
Appearance,
|
||||||
|
Notifications,
|
||||||
|
Keybinds,
|
||||||
|
Language,
|
||||||
|
}
|
|
@ -33,6 +33,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import CropPopup from '~/components/Popups/CropPopup.vue';
|
||||||
import UserPopup from '~/components/User/UserPopup.vue';
|
import UserPopup from '~/components/User/UserPopup.vue';
|
||||||
import Button from '~/components/UserInterface/Button.vue';
|
import Button from '~/components/UserInterface/Button.vue';
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ import type { UserResponse } from '~/types/interfaces';
|
||||||
let newPfpFile: File;
|
let newPfpFile: File;
|
||||||
const isCropPopupVisible = ref(false);
|
const isCropPopupVisible = ref(false);
|
||||||
const cropImageSrc = ref("")
|
const cropImageSrc = ref("")
|
||||||
;
|
|
||||||
const { fetchUser } = useAuth();
|
const { fetchUser } = useAuth();
|
||||||
|
|
||||||
const user: UserResponse | undefined = await fetchUser()
|
const user: UserResponse | undefined = await fetchUser()
|
||||||
|
|
13
components/Settings/UserSettings/index.ts
Normal file
13
components/Settings/UserSettings/index.ts
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import Profile from './Profile.vue';
|
||||||
|
import Account from './Account.vue';
|
||||||
|
import Privacy from './Privacy.vue';
|
||||||
|
import Devices from './Devices.vue';
|
||||||
|
import Connections from './Connections.vue';
|
||||||
|
|
||||||
|
export {
|
||||||
|
Profile,
|
||||||
|
Account,
|
||||||
|
Privacy,
|
||||||
|
Devices,
|
||||||
|
Connections,
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<NuxtLink class="user-item" :href="`/me/${user.uuid}`" tabindex="0">
|
<NuxtLink class="user-item" :href="`/me/${user.uuid}`" tabindex="0">
|
||||||
<img v-if="props.user.avatar" class="user-avatar" :src="props.user.avatar" :alt="props.user.display_name ?? props.user.username" />
|
<Avatar :user="props.user" class="user-avatar"/>
|
||||||
<Icon v-else class="user-avatar" name="lucide:user" />
|
|
||||||
<span class="user-display-name">{{ props.user.display_name || props.user.username }}</span>
|
<span class="user-display-name">{{ getDisplayName(props.user) }}</span>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import type { UserResponse } from '~/types/interfaces';
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
user: UserResponse
|
user: UserResponse
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -33,8 +34,15 @@ const props = defineProps<{
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-avatar {
|
.user-avatar {
|
||||||
width: 2.3em;
|
min-width: 2.3em;
|
||||||
height: 2.3em;
|
max-width: 2.3em;
|
||||||
border-radius: 50%;
|
min-width: 2.3em;
|
||||||
|
max-height: 2.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-display-name {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="profile-popup">
|
<div id="profile-popup">
|
||||||
<img v-if="props.user.avatar" id="avatar" :src="props.user.avatar" alt="profile avatar">
|
<Avatar :user="props.user" id="avatar"/>
|
||||||
<Icon v-else id="avatar" name="lucide:user" />
|
|
||||||
|
|
||||||
<div id="cover-color"></div>
|
<div id="cover-color"></div>
|
||||||
<div id="main-body">
|
<div id="main-body">
|
||||||
<p id="display-name">
|
<p id="display-name">
|
||||||
<strong>{{ props.user.display_name }}</strong>
|
<strong>{{ getDisplayName(props.user) }}</strong>
|
||||||
</p>
|
</p>
|
||||||
<p id="username-and-pronouns">
|
<p id="username-and-pronouns">
|
||||||
{{ props.user.username }}
|
{{ props.user.username }}
|
||||||
|
@ -22,8 +21,6 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { UserResponse } from '~/types/interfaces';
|
import type { UserResponse } from '~/types/interfaces';
|
||||||
|
|
||||||
const { fetchMembers } = useApi();
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
user: UserResponse
|
user: UserResponse
|
||||||
}>();
|
}>();
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<div @click="props.callback()" class="button" :class="props.variant + '-button'">
|
<button @click="props.callback ? props.callback() : null" class="button" :class="props.variant + '-button'">
|
||||||
{{ props.text }}
|
{{ props.text }}
|
||||||
</div>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
text: string,
|
text: string,
|
||||||
callback: CallableFunction,
|
callback?: CallableFunction,
|
||||||
variant?: "normal" | "scary" | "neutral",
|
variant?: "normal" | "scary" | "neutral",
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@ const props = defineProps<{
|
||||||
border-radius: 0.7rem;
|
border-radius: 0.7rem;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
||||||
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button:hover {
|
.button:hover {
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ContextMenuItem } from '~/types/interfaces';
|
import type { ContextMenuItem } from '~/types/interfaces';
|
||||||
|
|
||||||
const props = defineProps<{ menuItems: ContextMenuItem[], cursorX: number, cursorY: number }>();
|
const props = defineProps<{ menuItems: ContextMenuItem[], pointerX: number, pointerY: number }>();
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const contextMenu = document.getElementById("context-menu");
|
const contextMenu = document.getElementById("context-menu");
|
||||||
if (contextMenu) {
|
if (contextMenu) {
|
||||||
contextMenu.style.left = props.cursorX.toString() + "px";
|
contextMenu.style.left = props.pointerX.toString() + "px";
|
||||||
contextMenu.style.top = props.cursorY.toString() + "px";
|
contextMenu.style.top = props.pointerY.toString() + "px";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
140
components/UserInterface/ResizableSidebar.vue
Normal file
140
components/UserInterface/ResizableSidebar.vue
Normal file
|
@ -0,0 +1,140 @@
|
||||||
|
<template>
|
||||||
|
<div ref="resizableSidebar" class="resizable-sidebar"
|
||||||
|
:style="{
|
||||||
|
'width': storedWidth ? `${storedWidth}px` : props.width,
|
||||||
|
'min-width': props.minWidth,
|
||||||
|
'max-width': props.maxWidth,
|
||||||
|
'border': props.borderSides == 'all' ? borderStyling : undefined,
|
||||||
|
'border-top': props.borderSides?.includes('top') ? borderStyling : undefined,
|
||||||
|
'border-bottom': props.borderSides?.includes('bottom') ? borderStyling : undefined,
|
||||||
|
}">
|
||||||
|
<div v-if="props.borderSides != 'right'" class="width-resizer-bar">
|
||||||
|
<div ref="widthResizer" class="width-resizer"></div>
|
||||||
|
</div>
|
||||||
|
<div class="sidebar-content">
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
|
<div v-if="props.borderSides == 'right'" class="width-resizer-bar">
|
||||||
|
<div ref="widthResizer" class="width-resizer"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ContextMenuItem } from '~/types/interfaces';
|
||||||
|
|
||||||
|
const props = defineProps<{ width?: string, minWidth: string, maxWidth: string, borderSides: "all" | "top" | "right" | "bottom" | "left" | ("top" | "right" | "bottom" | "left")[], localStorageName?: string }>();
|
||||||
|
|
||||||
|
const borderStyling = ".1rem solid var(--padding-color)";
|
||||||
|
|
||||||
|
const resizableSidebar = ref<HTMLDivElement>();
|
||||||
|
const widthResizer = ref<HTMLDivElement>();
|
||||||
|
const storedWidth = ref<number>();
|
||||||
|
|
||||||
|
const menuItems: ContextMenuItem[] = [
|
||||||
|
{ name: "Reset", callback: () => { resizableSidebar.value!.style.width = props.width ?? props.minWidth } }
|
||||||
|
]
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadStoredWidth();
|
||||||
|
|
||||||
|
if (resizableSidebar.value && widthResizer.value) {
|
||||||
|
widthResizer.value.addEventListener("pointerdown", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
if (e.button == 2) {
|
||||||
|
createContextMenu(e, menuItems);
|
||||||
|
return
|
||||||
|
};
|
||||||
|
document.body.style.cursor = "ew-resize";
|
||||||
|
function handleMove(pointer: PointerEvent) {
|
||||||
|
if (resizableSidebar.value) {
|
||||||
|
console.log("moving");
|
||||||
|
console.log("pointer:", pointer);
|
||||||
|
console.log("width:", resizableSidebar.value.style.width);
|
||||||
|
let delta = 0;
|
||||||
|
if (props.borderSides == 'right') {
|
||||||
|
delta = resizableSidebar.value.getBoundingClientRect().left;
|
||||||
|
console.log("delta:", delta);
|
||||||
|
resizableSidebar.value.style.width = `${pointer.clientX - delta}px`;
|
||||||
|
} else {
|
||||||
|
delta = resizableSidebar.value.getBoundingClientRect().right;
|
||||||
|
console.log("delta:", delta);
|
||||||
|
resizableSidebar.value.style.width = `${delta - pointer.clientX}px`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("pointermove", handleMove);
|
||||||
|
|
||||||
|
document.addEventListener("pointerup", () => {
|
||||||
|
console.log("pointer up");
|
||||||
|
document.removeEventListener("pointermove", handleMove);
|
||||||
|
console.log("removed pointermove event listener");
|
||||||
|
document.body.style.cursor = "";
|
||||||
|
if (resizableSidebar.value && props.localStorageName) {
|
||||||
|
localStorage.setItem(props.localStorageName, resizableSidebar.value.style.width);
|
||||||
|
}
|
||||||
|
}, { once: true });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
onActivated(() => {
|
||||||
|
console.log("[res] activated");
|
||||||
|
loadStoredWidth();
|
||||||
|
});
|
||||||
|
|
||||||
|
function loadStoredWidth() {
|
||||||
|
if (props.localStorageName) {
|
||||||
|
const storedWidthValue = localStorage.getItem(props.localStorageName);
|
||||||
|
if (storedWidthValue) {
|
||||||
|
storedWidth.value = parseInt(storedWidthValue) || undefined;
|
||||||
|
console.log("[res] loaded stored width");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.resizable-sidebar > * {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.resizable-sidebar {
|
||||||
|
display: flex;
|
||||||
|
background: var(--optional-channel-list-background);
|
||||||
|
background-color: var(--sidebar-background-color);
|
||||||
|
height: 100%;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.width-resizer {
|
||||||
|
width: .5rem;
|
||||||
|
cursor: col-resize;
|
||||||
|
position: absolute;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.width-resizer-bar {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
position: relative;
|
||||||
|
height: 100%;
|
||||||
|
width: 1px;
|
||||||
|
background-color: var(--padding-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-content {
|
||||||
|
width: 100%;
|
||||||
|
padding-left: .25em;
|
||||||
|
padding-right: .25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-content > :first-child {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow-y: scroll;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,24 +1,36 @@
|
||||||
import type { ChannelResponse, GuildMemberResponse, GuildResponse, MessageResponse, StatsResponse, UserResponse } from "~/types/interfaces";
|
import type { ChannelResponse, GuildMemberResponse, GuildResponse, MessageResponse, StatsResponse, UserResponse } from "~/types/interfaces";
|
||||||
|
|
||||||
|
function ensureIsArray(list: any) {
|
||||||
|
if (Array.isArray(list)) {
|
||||||
|
return list
|
||||||
|
} else {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const useApi = () => {
|
export const useApi = () => {
|
||||||
async function fetchGuilds(): Promise<GuildResponse[] | undefined> {
|
async function fetchGuilds(): Promise<GuildResponse[]> {
|
||||||
return await fetchWithApi(`/guilds`);
|
return ensureIsArray(await fetchWithApi(`/guilds`));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchGuild(guildId: string): Promise<GuildResponse | undefined> {
|
async function fetchGuild(guildId: string): Promise<GuildResponse | undefined> {
|
||||||
return await fetchWithApi(`/guilds/${guildId}`);
|
return await fetchWithApi(`/guilds/${guildId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchChannels(guildId: string): Promise<ChannelResponse[] | undefined> {
|
async function fetchMyGuilds(): Promise<GuildResponse[]> {
|
||||||
return await fetchWithApi(`/guilds/${guildId}/channels`);
|
return ensureIsArray(await fetchWithApi(`/me/guilds`));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchChannels(guildId: string): Promise<ChannelResponse[]> {
|
||||||
|
return ensureIsArray(await fetchWithApi(`/guilds/${guildId}/channels`));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchChannel(channelId: string): Promise<ChannelResponse | undefined> {
|
async function fetchChannel(channelId: string): Promise<ChannelResponse | undefined> {
|
||||||
return await fetchWithApi(`/channels/${channelId}`)
|
return await fetchWithApi(`/channels/${channelId}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchMembers(guildId: string): Promise<GuildMemberResponse[] | undefined> {
|
async function fetchMembers(guildId: string): Promise<GuildMemberResponse[]> {
|
||||||
return await fetchWithApi(`/guilds/${guildId}/members`);
|
return ensureIsArray(await fetchWithApi(`/guilds/${guildId}/members`));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchMember(guildId: string, memberId: string): Promise<GuildMemberResponse | undefined> {
|
async function fetchMember(guildId: string, memberId: string): Promise<GuildMemberResponse | undefined> {
|
||||||
|
@ -33,8 +45,8 @@ export const useApi = () => {
|
||||||
return await fetchWithApi(`/users/${userId}`);
|
return await fetchWithApi(`/users/${userId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchFriends(): Promise<UserResponse[] | undefined> {
|
async function fetchFriends(): Promise<UserResponse[]> {
|
||||||
return await fetchWithApi('/me/friends')
|
return ensureIsArray(await fetchWithApi('/me/friends'));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addFriend(username: string): Promise<void> {
|
async function addFriend(username: string): Promise<void> {
|
||||||
|
@ -74,9 +86,22 @@ export const useApi = () => {
|
||||||
await fetchWithApi("/auth/verify-email", { method: "POST", body: { email } });
|
await fetchWithApi("/auth/verify-email", { method: "POST", body: { email } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function sendPasswordResetEmail(identifier: string): Promise<void> {
|
||||||
|
await fetchWithApi("/auth/reset-password", { method: "GET", query: { identifier } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function resetPassword(password: string, token: string) {
|
||||||
|
await fetchWithApi("/auth/reset-password", { method: "POST", body: { password, token } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchInvite(id: string): Promise<GuildResponse | undefined> {
|
||||||
|
return await fetchWithApi(`/invites/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fetchGuilds,
|
fetchGuilds,
|
||||||
fetchGuild,
|
fetchGuild,
|
||||||
|
fetchMyGuilds,
|
||||||
fetchChannels,
|
fetchChannels,
|
||||||
fetchChannel,
|
fetchChannel,
|
||||||
fetchMembers,
|
fetchMembers,
|
||||||
|
@ -92,6 +117,9 @@ export const useApi = () => {
|
||||||
joinGuild,
|
joinGuild,
|
||||||
createChannel,
|
createChannel,
|
||||||
fetchInstanceStats,
|
fetchInstanceStats,
|
||||||
sendVerificationEmail
|
sendVerificationEmail,
|
||||||
|
sendPasswordResetEmail,
|
||||||
|
resetPassword,
|
||||||
|
fetchInvite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ export const useAuth = () => {
|
||||||
async function logout() {
|
async function logout() {
|
||||||
console.log("access:", accessToken.value);
|
console.log("access:", accessToken.value);
|
||||||
|
|
||||||
await fetchWithApi("/auth/logout", { method: "GET", credentials: "include" });
|
await fetchWithApi("/auth/logout", { method: "DELETE", credentials: "include" });
|
||||||
clearAuth();
|
clearAuth();
|
||||||
|
|
||||||
return await navigateTo("/login");
|
return await navigateTo("/login");
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div v-else id="auth-form-container">
|
<div v-else id="auth-form-container">
|
||||||
<slot />
|
<slot />
|
||||||
|
<div v-if="!['/recover', '/reset-password'].includes(route.path)">Forgot password? Recover <NuxtLink href="/recover">here</NuxtLink>!</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="instanceUrl">
|
<div v-if="instanceUrl">
|
||||||
Instance URL is set to <span style="color: var(--primary-color);">{{ instanceUrl }}</span>
|
Instance URL is set to <span style="color: var(--primary-color);">{{ instanceUrl }}</span>
|
||||||
|
@ -36,7 +37,11 @@ const apiVersion = useRuntimeConfig().public.apiVersion;
|
||||||
const apiBase = useCookie("api_base");
|
const apiBase = useCookie("api_base");
|
||||||
const registrationEnabled = useState("registrationEnabled", () => true);
|
const registrationEnabled = useState("registrationEnabled", () => true);
|
||||||
|
|
||||||
const auth = useAuth();
|
const route = useRoute();
|
||||||
|
|
||||||
|
const query = route.query as Record<string, string>;
|
||||||
|
const searchParams = new URLSearchParams(query);
|
||||||
|
searchParams.delete("token");
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
instanceUrl.value = useCookie("instance_url").value;
|
instanceUrl.value = useCookie("instance_url").value;
|
||||||
|
@ -111,6 +116,7 @@ const form = reactive({
|
||||||
#auth-form-container form {
|
#auth-form-container form {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
margin-top: 10dvh;
|
margin-top: 10dvh;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
|
|
|
@ -8,27 +8,39 @@
|
||||||
</marquee>
|
</marquee>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id = "page-content">
|
<div id="page-content">
|
||||||
<div id="left-column">
|
<div id="left-column">
|
||||||
<div id="left-column-top">
|
<div class="left-column-segment">
|
||||||
<NuxtLink id="home-button" href="/me">
|
<NuxtLink id="home-button" href="/me">
|
||||||
<img class="sidebar-icon" src="/public/icon.svg"/>
|
<img class="sidebar-icon" src="/public/icon.svg"/>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<div id="servers-list">
|
|
||||||
<NuxtLink v-for="guild of guilds" :href="`/servers/${guild.uuid}`">
|
|
||||||
<img v-if="guild.icon" class="sidebar-icon" :src="guild.icon" :alt="guild.name"/>
|
|
||||||
<Icon v-else name="lucide:server" class="sidebar-icon white" :alt="guild.name" />
|
|
||||||
</NuxtLink>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="left-column-bottom">
|
<VerticalSpacer />
|
||||||
|
<div class="left-column-segment" id="left-column-middle">
|
||||||
|
<NuxtLink v-for="guild of guilds" :href="`/servers/${guild.uuid}`">
|
||||||
|
<NuxtImg v-if="guild.icon"
|
||||||
|
class="sidebar-icon guild-icon"
|
||||||
|
:alt="guild.name"
|
||||||
|
:src="guild.icon" />
|
||||||
|
<NuxtImg v-else-if="!blockedCanvas"
|
||||||
|
class="sidebar-icon guild-icon"
|
||||||
|
:alt="guild.name"
|
||||||
|
:src="generateDefaultIcon(guild.name, guild.uuid)" />
|
||||||
|
<Icon v-else name="lucide:server"
|
||||||
|
:style="`color: ${generateIrcColor(guild.uuid, 50)}`"
|
||||||
|
class="sidebar-icon guild-icon"
|
||||||
|
:alt="guild.name" />
|
||||||
|
</NuxtLink>
|
||||||
|
</div>
|
||||||
|
<VerticalSpacer />
|
||||||
|
<div class="left-column-segment">
|
||||||
<div ref="createButtonContainer">
|
<div ref="createButtonContainer">
|
||||||
<button id="create-button" @click.prevent="createDropdown">
|
<button id="create-button" class="sidebar-bottom-buttons" @click.prevent="createDropdown">
|
||||||
<Icon id="create-icon" name="lucide:square-plus" />
|
<Icon id="create-icon" name="lucide:square-plus" alt="Create or join guild"/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<NuxtLink id="settings-menu" href="/settings">
|
<NuxtLink id="settings-menu" class="sidebar-bottom-buttons" href="/settings">
|
||||||
<Icon name="lucide:settings" class="sidebar-icon" alt="Settings menu" />
|
<Icon name="lucide:settings" alt="Settings menu" />
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -38,10 +50,11 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { ModalBase } from '#components';
|
||||||
import { render } from 'vue';
|
import { render } from 'vue';
|
||||||
import GuildDropdown from '~/components/Guild/GuildDropdown.vue';
|
import GuildDropdown from '~/components/Guild/GuildDropdown.vue';
|
||||||
import Modal from '~/components/Modals/Modal.vue';
|
|
||||||
import Button from '~/components/UserInterface/Button.vue';
|
import Button from '~/components/UserInterface/Button.vue';
|
||||||
|
import VerticalSpacer from '~/components/UserInterface/VerticalSpacer.vue';
|
||||||
import type { GuildResponse } from '~/types/interfaces';
|
import type { GuildResponse } from '~/types/interfaces';
|
||||||
|
|
||||||
const loading = useState("loading", () => false);
|
const loading = useState("loading", () => false);
|
||||||
|
@ -50,11 +63,13 @@ const createButtonContainer = ref<HTMLButtonElement>();
|
||||||
|
|
||||||
const api = useApi();
|
const api = useApi();
|
||||||
|
|
||||||
|
const blockedCanvas = isCanvasBlocked()
|
||||||
|
|
||||||
const options = [
|
const options = [
|
||||||
{ name: "Join", value: "join", callback: async () => {
|
{ name: "Join", value: "join", callback: async () => {
|
||||||
console.log("join guild!");
|
console.log("join guild!");
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
const guildJoinModal = h(Modal, {
|
const guildJoinModal = h(ModalBase, {
|
||||||
title: "Join Guild",
|
title: "Join Guild",
|
||||||
id: "guild-join-modal",
|
id: "guild-join-modal",
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
|
@ -80,7 +95,7 @@ const options = [
|
||||||
if (invite.length == 6) {
|
if (invite.length == 6) {
|
||||||
try {
|
try {
|
||||||
const joinedGuild = await api.joinGuild(invite);
|
const joinedGuild = await api.joinGuild(invite);
|
||||||
guilds?.push(joinedGuild);
|
guilds.push(joinedGuild);
|
||||||
return await navigateTo(`/servers/${joinedGuild.uuid}`);
|
return await navigateTo(`/servers/${joinedGuild.uuid}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(`Couldn't use invite: ${error}`);
|
alert(`Couldn't use invite: ${error}`);
|
||||||
|
@ -97,7 +112,7 @@ const options = [
|
||||||
console.log("create guild");
|
console.log("create guild");
|
||||||
const user = await useAuth().getUser();
|
const user = await useAuth().getUser();
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
const guildCreateModal = h(Modal, {
|
const guildCreateModal = h(ModalBase, {
|
||||||
title: "Create a Guild",
|
title: "Create a Guild",
|
||||||
id: "guild-join-modal",
|
id: "guild-join-modal",
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
|
@ -112,7 +127,7 @@ const options = [
|
||||||
h("input", {
|
h("input", {
|
||||||
id: "guild-name-input",
|
id: "guild-name-input",
|
||||||
type: "text",
|
type: "text",
|
||||||
placeholder: `${user?.display_name || user?.username}'s Awesome Bouncy Castle'`,
|
placeholder: `${getDisplayName(user!)}'s Awesome Bouncy Castle'`,
|
||||||
style: "width: 100%"
|
style: "width: 100%"
|
||||||
}),
|
}),
|
||||||
h(Button, {
|
h(Button, {
|
||||||
|
@ -136,48 +151,7 @@ const options = [
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const guilds: GuildResponse[] | undefined = await fetchWithApi("/me/guilds");
|
const guilds = await api.fetchMyGuilds();
|
||||||
|
|
||||||
//const servers = await fetchWithApi("/servers") as { uuid: string, name: string, description: string }[];
|
|
||||||
//console.log("servers:", servers);
|
|
||||||
const members = [
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "3287484395",
|
|
||||||
displayName: "SauceyRed"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
function createDropdown() {
|
function createDropdown() {
|
||||||
const dropdown = h(GuildDropdown, { options });
|
const dropdown = h(GuildDropdown, { options });
|
||||||
|
@ -243,92 +217,59 @@ function createDropdown() {
|
||||||
#left-column {
|
#left-column {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
padding-left: var(--sidebar-margin);
|
||||||
gap: .75em;
|
padding-right: var(--sidebar-margin);
|
||||||
padding-left: .25em;
|
|
||||||
padding-right: .25em;
|
|
||||||
padding-top: .5em;
|
padding-top: .5em;
|
||||||
border-right: 1px solid var(--padding-color);
|
|
||||||
background: var(--optional-sidebar-background);
|
background: var(--optional-sidebar-background);
|
||||||
background-color: var(--sidebar-background-color);
|
background-color: var(--sidebar-background-color);
|
||||||
|
|
||||||
|
border-right: 1px solid var(--padding-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
#left-column-top, #left-column-bottom {
|
.left-column-segment {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
scrollbar-width: none;
|
||||||
gap: 1.5dvh;
|
}
|
||||||
|
|
||||||
|
.left-column-segment::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#left-column-middle {
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
flex-grow: 1;
|
||||||
|
gap: var(--sidebar-icon-gap);
|
||||||
#left-column-bottom {
|
|
||||||
padding-top: 1dvh;
|
|
||||||
border-top: 1px solid var(--padding-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
#middle-left-column {
|
|
||||||
padding-left: 1dvw;
|
|
||||||
padding-right: 1dvw;
|
|
||||||
border-right: 1px solid var(--padding-color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#home-button {
|
#home-button {
|
||||||
border-bottom: 1px solid var(--padding-color);
|
height: var(--sidebar-icon-width);
|
||||||
padding-bottom: 1dvh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#servers-list {
|
.guild-icon {
|
||||||
display: flex;
|
border-radius: var(--guild-icon-radius);
|
||||||
flex-direction: column;
|
|
||||||
gap: 1em;
|
|
||||||
width: 3.2rem;
|
|
||||||
padding-top: .5em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#create-button {
|
.sidebar-icon {
|
||||||
|
width: var(--sidebar-icon-width);
|
||||||
|
height: var(--sidebar-icon-width);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-bottom-buttons {
|
||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 2rem;
|
font-size: 2.4rem;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
#create-icon {
|
.sidebar-bottom-buttons:hover {
|
||||||
float: left;
|
color: var(--primary-highlighted-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
#middle-left-column {
|
</style>
|
||||||
padding-left: .25em;
|
|
||||||
padding-right: .25em;
|
|
||||||
border-right: 1px solid var(--padding-color);
|
|
||||||
min-width: 13em;
|
|
||||||
max-width: 13em;
|
|
||||||
overflow-y: scroll;
|
|
||||||
overflow-x: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar-icon {
|
|
||||||
width: 3rem;
|
|
||||||
height: 3rem;
|
|
||||||
overflow-y: scroll;
|
|
||||||
overflow-x: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
#home-button {
|
|
||||||
border-bottom: 1px solid var(--padding-color);
|
|
||||||
padding-bottom: .375em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#settings-menu {
|
|
||||||
color: var(--primary-color)
|
|
||||||
}
|
|
||||||
|
|
||||||
#settings-menu:hover {
|
|
||||||
color: var(--primary-highlighted-color)
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (["/login", "/register"].includes(to.path) && !Object.keys(to.query).includes("special")) {
|
if (["/login", "/register", "/recover", "/reset-password"].includes(to.path) && !Object.keys(to.query).includes("special")) {
|
||||||
console.log("path is login or register");
|
console.log("path is login or register");
|
||||||
const apiBase = useCookie("api_base");
|
const apiBase = useCookie("api_base");
|
||||||
console.log("apiBase gotten:", apiBase.value);
|
console.log("apiBase gotten:", apiBase.value);
|
||||||
|
|
|
@ -5,10 +5,10 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||||
|
|
||||||
const guildId = to.params.serverId as string;
|
const guildId = to.params.serverId as string;
|
||||||
|
|
||||||
const channels: ChannelResponse[] | undefined = await fetchChannels(guildId);
|
const channels: ChannelResponse[] = await fetchChannels(guildId);
|
||||||
console.log("channels:", channels);
|
console.log("channels:", channels);
|
||||||
|
|
||||||
if (channels && channels.length > 0) {
|
if (channels.length > 0) {
|
||||||
console.log("wah");
|
console.log("wah");
|
||||||
return await navigateTo(`/servers/${guildId}/channels/${channels[0].uuid}`, { replace: true });
|
return await navigateTo(`/servers/${guildId}/channels/${channels[0].uuid}`, { replace: true });
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
"pinia-plugin-persistedstate": "^4.2.0",
|
"pinia-plugin-persistedstate": "^4.2.0",
|
||||||
"typescript": "^5.8.3",
|
"typescript": "^5.8.3",
|
||||||
"vue": "^3.5.13",
|
"vue": "^3.5.13",
|
||||||
"vue-router": "^4.5.1"
|
"vue-router": "^4.5.1",
|
||||||
|
"xxhash-wasm": "^1.1.0"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@10.11.0",
|
"packageManager": "pnpm@10.11.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
180
pages/invite/[inviteId].vue
Normal file
180
pages/invite/[inviteId].vue
Normal file
|
@ -0,0 +1,180 @@
|
||||||
|
<template>
|
||||||
|
<div id="invite-root">
|
||||||
|
<div id="invite-container">
|
||||||
|
<div id="guild-container" v-if="guild">
|
||||||
|
<h1>You have been invited to {{ guild.name }}!</h1>
|
||||||
|
<div id="guild-card">
|
||||||
|
<div id="card-grid">
|
||||||
|
<div id="guild-details">
|
||||||
|
<div id="guild-name" title="Server name">
|
||||||
|
<span>{{ guild.name }}</span>
|
||||||
|
</div>
|
||||||
|
<div id="guild-member-count" :title="`${guild.member_count} members`">
|
||||||
|
<Icon name="lucide:users" />
|
||||||
|
<span>{{ guild.member_count }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<VerticalSpacer id="space" />
|
||||||
|
<div id="guild-description">
|
||||||
|
<span>{{ guild.description }}</span>
|
||||||
|
</div>
|
||||||
|
<div id="guild-icon">
|
||||||
|
<NuxtImg v-if="guild.icon" id="guild-icon-img" :src="guild.icon" :alt="`${guild.name} server icon`" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Button :text="isMember ? 'Joined' : 'Join'" variant="normal" :callback="acceptInvite" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="errorMessage">
|
||||||
|
<h1>{{ errorMessage }}</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import Button from '~/components/UserInterface/Button.vue';
|
||||||
|
import VerticalSpacer from '~/components/UserInterface/VerticalSpacer.vue';
|
||||||
|
import type { GuildResponse } from '~/types/interfaces';
|
||||||
|
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const { fetchInvite, joinGuild, fetchMembers } = useApi();
|
||||||
|
const { getUser } = useAuth();
|
||||||
|
|
||||||
|
const inviteId = route.params.inviteId as string;
|
||||||
|
|
||||||
|
const guild = ref<GuildResponse>();
|
||||||
|
const errorMessage = ref<string>();
|
||||||
|
const isMember = ref(false);
|
||||||
|
|
||||||
|
const accessToken = useCookie("access_token");
|
||||||
|
|
||||||
|
if (inviteId) {
|
||||||
|
try {
|
||||||
|
guild.value = await fetchInvite(inviteId);
|
||||||
|
console.log("invite guild:", guild.value);
|
||||||
|
if (accessToken.value && guild.value) {
|
||||||
|
const members = await fetchMembers(guild.value.uuid);
|
||||||
|
const me = await getUser();
|
||||||
|
if (me && members.find(member => member.user.uuid == me.uuid)) {
|
||||||
|
isMember.value = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error.response) {
|
||||||
|
if (error.status == 404) {
|
||||||
|
errorMessage.value = "That invite doesn't exist or has expired.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function acceptInvite() {
|
||||||
|
if (accessToken.value && guild.value) {
|
||||||
|
await joinGuild(inviteId);
|
||||||
|
return await navigateTo(`/servers/${guild.value.uuid}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return await navigateTo(`/login?redirect_to=${route.fullPath}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
#invite-root {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100dvh;
|
||||||
|
}
|
||||||
|
|
||||||
|
#invite-container {
|
||||||
|
border: .5rem solid var(--chat-highlighted-background-color);
|
||||||
|
border-radius: var(--standard-radius);
|
||||||
|
height: 50%;
|
||||||
|
width: 50%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
width: 50%;
|
||||||
|
height: 60%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#guild-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
width: 50%;
|
||||||
|
height: 60%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#guild-card {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
background-color: var(--sidebar-highlighted-background-color);
|
||||||
|
border: .5rem solid black;
|
||||||
|
border-radius: var(--standard-radius);
|
||||||
|
padding: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#card-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
|
grid-template-rows: 5rem auto 1fr;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#guild-details {
|
||||||
|
grid-row: 1;
|
||||||
|
grid-column: span 2;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#guild-name {
|
||||||
|
font-size: 2rem;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
#guild-member-count {
|
||||||
|
gap: .3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#space {
|
||||||
|
grid-row: 2;
|
||||||
|
grid-column: span 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
#guild-description {
|
||||||
|
grid-row: 3;
|
||||||
|
grid-column: span 3;
|
||||||
|
word-break: break-all;
|
||||||
|
padding: .3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
#guild-name, #guild-member-count {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#guild-icon-img {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
object-fit: scale-down;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
|
@ -22,8 +22,6 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { StatsResponse } from '~/types/interfaces';
|
|
||||||
|
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: "auth"
|
layout: "auth"
|
||||||
|
@ -38,6 +36,7 @@ const form = reactive({
|
||||||
|
|
||||||
const query = useRoute().query as Record<string, string>;
|
const query = useRoute().query as Record<string, string>;
|
||||||
const searchParams = new URLSearchParams(query);
|
const searchParams = new URLSearchParams(query);
|
||||||
|
searchParams.delete("token");
|
||||||
|
|
||||||
const registrationEnabled = ref<boolean>(true);
|
const registrationEnabled = ref<boolean>(true);
|
||||||
const apiBase = useCookie("api_base");
|
const apiBase = useCookie("api_base");
|
||||||
|
@ -50,7 +49,7 @@ if (apiBase.value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const registerUrl = `/register?${searchParams}`
|
const registerUrl = `/register?${searchParams}`;
|
||||||
|
|
||||||
const { login } = useAuth();
|
const { login } = useAuth();
|
||||||
|
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
<template>
|
|
||||||
<NuxtLayout name="client">
|
|
||||||
<DirectMessagesSidebar />
|
|
||||||
<div :id="$style['page-content']">
|
|
||||||
<div :id="$style['navigation-bar']">
|
|
||||||
<Button :text="`All Friends – ${friends?.length}`" variant="neutral" :callback="() => updateFilter('all')" />
|
|
||||||
<Button :text="`Online – ${0}`" variant="neutral" :callback="() => updateFilter('online')" />
|
|
||||||
<Button :text="`Pending – ${0}`" variant="neutral" :callback="() => updateFilter('pending')" />
|
|
||||||
<Button text="Add Friend" variant="normal" :callback="() => updateFilter('add')" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<AddFriend v-if="filter == 'add'"></AddFriend>
|
|
||||||
<FriendsList v-else :variant="filter"></FriendsList>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</NuxtLayout>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import DirectMessagesSidebar from '~/components/Me/DirectMessagesSidebar.vue';
|
|
||||||
import Button from '~/components/UserInterface/Button.vue';
|
|
||||||
import AddFriend from '~/components/Me/AddFriend.vue';
|
|
||||||
import FriendsList from '~/components/Me/FriendsList.vue';
|
|
||||||
|
|
||||||
const { fetchFriends } = useApi();
|
|
||||||
|
|
||||||
let filter = ref("all");
|
|
||||||
|
|
||||||
const friends = await fetchFriends()
|
|
||||||
|
|
||||||
function updateFilter(newFilter: string) {
|
|
||||||
filter.value = newFilter;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style module>
|
|
||||||
#page-content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
flex-grow: 1;
|
|
||||||
|
|
||||||
margin: .75em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#navigation-bar {
|
|
||||||
display: flex;
|
|
||||||
align-items: left;
|
|
||||||
text-align: left;
|
|
||||||
flex-direction: row;
|
|
||||||
|
|
||||||
gap: .5em;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,13 +1,56 @@
|
||||||
<template>
|
<template>
|
||||||
<NuxtLayout name="client">
|
<NuxtLayout name="client">
|
||||||
<DirectMessagesSidebar />
|
<DirectMessagesSidebar />
|
||||||
|
<div :id="$style['page-content']">
|
||||||
|
<div :id="$style['navigation-bar']">
|
||||||
|
<Button :text="`All Friends – ${friends?.length}`" variant="neutral" :callback="() => updateFilter('all')" />
|
||||||
|
<Button :text="`Online – ${0}`" variant="neutral" :callback="() => updateFilter('online')" />
|
||||||
|
<Button :text="`Pending – ${0}`" variant="neutral" :callback="() => updateFilter('pending')" />
|
||||||
|
<Button text="Add Friend" variant="normal" :callback="() => updateFilter('add')" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<AddFriend v-if="filter == 'add'"></AddFriend>
|
||||||
|
<FriendsList v-else :variant="filter"></FriendsList>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</NuxtLayout>
|
</NuxtLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import DirectMessagesSidebar from '~/components/Me/DirectMessagesSidebar.vue';
|
import DirectMessagesSidebar from '~/components/Me/DirectMessagesSidebar.vue';
|
||||||
|
import Button from '~/components/UserInterface/Button.vue';
|
||||||
|
import AddFriend from '~/components/Me/AddFriend.vue';
|
||||||
|
import FriendsList from '~/components/Me/FriendsList.vue';
|
||||||
|
|
||||||
|
const { fetchFriends } = useApi();
|
||||||
|
|
||||||
|
let filter = ref("all");
|
||||||
|
|
||||||
|
const friends = await fetchFriends()
|
||||||
|
|
||||||
|
function updateFilter(newFilter: string) {
|
||||||
|
filter.value = newFilter;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style module>
|
||||||
|
#page-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
flex-grow: 1;
|
||||||
|
|
||||||
|
margin: .75em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navigation-bar {
|
||||||
|
display: flex;
|
||||||
|
align-items: left;
|
||||||
|
text-align: left;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
gap: .5em;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
89
pages/recover.vue
Normal file
89
pages/recover.vue
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
<template>
|
||||||
|
<NuxtLayout name="auth">
|
||||||
|
<div v-if="errorValue">{{ errorValue }}</div>
|
||||||
|
<form v-if="!emailFormSent" @submit.prevent="sendEmail">
|
||||||
|
<div>
|
||||||
|
<label for="identifier">Email or username</label>
|
||||||
|
<br>
|
||||||
|
<input type="text" name="identifier" id="identifier" v-model="emailForm.identifier">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Button type="submit" text="Send email" variant="normal" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div v-else>
|
||||||
|
If an account with that username or email exists, an email will be sent to it shortly.
|
||||||
|
</div>
|
||||||
|
<div v-if="registrationEnabled">
|
||||||
|
Don't have an account? <NuxtLink :href="registerUrl">Register</NuxtLink> one!
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
Already have an account? <NuxtLink :href="loginUrl">Log in</NuxtLink>!
|
||||||
|
</div>
|
||||||
|
</NuxtLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import Button from '~/components/UserInterface/Button.vue';
|
||||||
|
|
||||||
|
const emailForm = reactive({
|
||||||
|
identifier: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
const emailFormSent = ref(false);
|
||||||
|
|
||||||
|
const passwordForm = reactive({
|
||||||
|
password: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
const errorValue = ref<string>();
|
||||||
|
|
||||||
|
const registrationEnabled = ref<boolean>(true);
|
||||||
|
const apiBase = useCookie("api_base");
|
||||||
|
|
||||||
|
const query = useRoute().query as Record<string, string>;
|
||||||
|
const searchParams = new URLSearchParams(query);
|
||||||
|
|
||||||
|
const token = ref(searchParams.get("token"))
|
||||||
|
searchParams.delete("token");
|
||||||
|
const { resetPassword } = useApi();
|
||||||
|
|
||||||
|
const registerUrl = `/register?${searchParams}`;
|
||||||
|
const loginUrl = `/login?${searchParams}`;
|
||||||
|
|
||||||
|
if (apiBase.value) {
|
||||||
|
console.log("apiBase:", apiBase.value);
|
||||||
|
const stats = await useApi().fetchInstanceStats(apiBase.value);
|
||||||
|
if (stats) {
|
||||||
|
registrationEnabled.value = stats.registration_enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const { sendPasswordResetEmail } = useApi();
|
||||||
|
|
||||||
|
async function sendEmail() {
|
||||||
|
try {
|
||||||
|
await sendPasswordResetEmail(emailForm.identifier);
|
||||||
|
emailFormSent.value = true;
|
||||||
|
} catch (error) {
|
||||||
|
errorValue.value = (error as any).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sendPassword() {
|
||||||
|
try {
|
||||||
|
console.log("pass:", passwordForm.password);
|
||||||
|
const hashedPass = await hashPassword(passwordForm.password)
|
||||||
|
console.log("hashed pass:", hashedPass);
|
||||||
|
await resetPassword(hashedPass, token.value!);
|
||||||
|
return await navigateTo(`/login?${searchParams}`);
|
||||||
|
} catch (error) {
|
||||||
|
errorValue.value = (error as any).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
|
@ -86,6 +86,7 @@ const auth = useAuth();
|
||||||
const loggedIn = ref(await auth.getUser());
|
const loggedIn = ref(await auth.getUser());
|
||||||
|
|
||||||
const query = new URLSearchParams(useRoute().query as Record<string, string>);
|
const query = new URLSearchParams(useRoute().query as Record<string, string>);
|
||||||
|
query.delete("token");
|
||||||
|
|
||||||
const user = await useAuth().getUser();
|
const user = await useAuth().getUser();
|
||||||
|
|
||||||
|
|
56
pages/reset-password.vue
Normal file
56
pages/reset-password.vue
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<template>
|
||||||
|
<NuxtLayout name="auth">
|
||||||
|
<div v-if="errorValue">{{ errorValue }}</div>
|
||||||
|
<form @submit.prevent="sendPassword">
|
||||||
|
<div>
|
||||||
|
<label for="password">Password</label>
|
||||||
|
<br>
|
||||||
|
<input type="password" name="password" id="password" v-model="passwordForm.password">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Button type="submit" text="Submit" variant="normal" />
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div>
|
||||||
|
Already have an account? <NuxtLink :href="loginUrl">Log in</NuxtLink>!
|
||||||
|
</div>
|
||||||
|
</NuxtLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import Button from '~/components/UserInterface/Button.vue';
|
||||||
|
|
||||||
|
const query = useRoute().query as Record<string, string>;
|
||||||
|
const searchParams = new URLSearchParams(query);
|
||||||
|
|
||||||
|
const loginUrl = `/login?${searchParams}`;
|
||||||
|
|
||||||
|
const token = ref(searchParams.get("token"))
|
||||||
|
|
||||||
|
if (!token.value) await navigateTo("/login");
|
||||||
|
|
||||||
|
const passwordForm = reactive({
|
||||||
|
password: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
const errorValue = ref<string>();
|
||||||
|
|
||||||
|
const { resetPassword } = useApi();
|
||||||
|
|
||||||
|
async function sendPassword() {
|
||||||
|
try {
|
||||||
|
console.log("pass:", passwordForm.password);
|
||||||
|
const hashedPass = await hashPassword(passwordForm.password)
|
||||||
|
console.log("hashed pass:", hashedPass);
|
||||||
|
await resetPassword(hashedPass, token.value!);
|
||||||
|
return await navigateTo("/login?");
|
||||||
|
} catch (error) {
|
||||||
|
errorValue.value = (error as any).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
|
@ -1,33 +1,42 @@
|
||||||
<template>
|
<template>
|
||||||
<NuxtLayout name="client">
|
<NuxtLayout name="client">
|
||||||
<div id="middle-left-column" class="main-grid-row">
|
<ResizableSidebar
|
||||||
<div id="server-name-container">
|
width="14rem" min-width="8rem" max-width="30rem"
|
||||||
<span id="server-name">{{ server?.name }}</span>
|
border-sides="right" local-storage-name="middleLeftColumn">
|
||||||
<button id="server-settings-button" @click="toggleGuildSettings">
|
<div id="middle-left-column" class="main-grid-row">
|
||||||
<Icon id="server-settings-icon" name="lucide:chevron-down" />
|
<div id="server-name-container">
|
||||||
</button>
|
<span id="server-name" :title="server?.name">{{ server?.name }}</span>
|
||||||
<GuildOptionsMenu v-if="showGuildSettings" />
|
<button id="server-settings-button" @click="toggleGuildSettings">
|
||||||
|
<Icon id="server-settings-icon" name="lucide:chevron-down" />
|
||||||
|
</button>
|
||||||
|
<GuildOptionsMenu v-if="showGuildSettings" />
|
||||||
|
</div>
|
||||||
|
<div id="channels-list">
|
||||||
|
<ChannelEntry v-for="channel of channels" :name="channel.name"
|
||||||
|
:uuid="channel.uuid" :current-uuid="(route.params.channelId as string)"
|
||||||
|
:href="`/servers/${route.params.serverId}/channels/${channel.uuid}`" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="channels-list">
|
</ResizableSidebar>
|
||||||
<ChannelEntry v-for="channel of channels" :name="channel.name"
|
|
||||||
:uuid="channel.uuid" :current-uuid="(route.params.channelId as string)"
|
|
||||||
:href="`/servers/${route.params.serverId}/channels/${channel.uuid}`" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<MessageArea :channel-url="channelUrlPath" />
|
<MessageArea :channel-url="channelUrlPath" />
|
||||||
<div id="members-container">
|
<ResizableSidebar
|
||||||
<div id="members-list">
|
width="14rem" min-width="5.5rem" max-width="30rem"
|
||||||
<MemberEntry v-for="member of members" :member="member" tabindex="0"/>
|
border-sides="left" local-storage-name="membersListWidth">
|
||||||
|
<div id="members-container">
|
||||||
|
<div id="members-list">
|
||||||
|
<MemberEntry v-for="member of members" :member="member" tabindex="0"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</ResizableSidebar>
|
||||||
</NuxtLayout>
|
</NuxtLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import ChannelEntry from "~/components/Guild/ChannelEntry.vue";
|
import ChannelEntry from "~/components/Guild/ChannelEntry.vue";
|
||||||
import GuildOptionsMenu from "~/components/Guild/GuildOptionsMenu.vue";
|
import GuildOptionsMenu from "~/components/Guild/GuildOptionsMenu.vue";
|
||||||
import MemberEntry from "~/components/Member/MemberEntry.vue";
|
import MemberEntry from "~/components/Guild/MemberEntry.vue";
|
||||||
import type { ChannelResponse, GuildMemberResponse, GuildResponse, MessageResponse } from "~/types/interfaces";
|
import ResizableSidebar from "~/components/UserInterface/ResizableSidebar.vue";
|
||||||
|
import type { ChannelResponse, GuildMemberResponse, GuildResponse } from "~/types/interfaces";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
@ -53,18 +62,22 @@ onMounted(async () => {
|
||||||
console.log("mounting");
|
console.log("mounting");
|
||||||
const guildUrl = `guilds/${route.params.serverId}`;
|
const guildUrl = `guilds/${route.params.serverId}`;
|
||||||
server.value = await fetchWithApi(guildUrl);
|
server.value = await fetchWithApi(guildUrl);
|
||||||
|
console.log("fetched guild");
|
||||||
await setArrayVariables();
|
await setArrayVariables();
|
||||||
|
console.log("set array variables");
|
||||||
});
|
});
|
||||||
|
|
||||||
onActivated(async () => {
|
onActivated(async () => {
|
||||||
console.log("activating");
|
console.log("activating");
|
||||||
const guildUrl = `guilds/${route.params.serverId}`;
|
const guildUrl = `guilds/${route.params.serverId}`;
|
||||||
server.value = await fetchWithApi(guildUrl);
|
server.value = await fetchWithApi(guildUrl);
|
||||||
|
console.log("fetched guild");
|
||||||
await setArrayVariables();
|
await setArrayVariables();
|
||||||
|
console.log("set array variables");
|
||||||
});
|
});
|
||||||
|
|
||||||
async function setArrayVariables() {
|
async function setArrayVariables() {
|
||||||
members.value = await fetchMembers(route.params.serverId as string);
|
members.value = sortMembers(await fetchMembers(route.params.serverId as string))
|
||||||
const guildUrl = `guilds/${route.params.serverId}`;
|
const guildUrl = `guilds/${route.params.serverId}`;
|
||||||
channels.value = await fetchWithApi(`${guildUrl}/channels`);
|
channels.value = await fetchWithApi(`${guildUrl}/channels`);
|
||||||
console.log("channels:", channels.value);
|
console.log("channels:", channels.value);
|
||||||
|
@ -87,18 +100,7 @@ function handleMemberClick(member: GuildMemberResponse) {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#middle-left-column {
|
|
||||||
padding-left: .5em;
|
|
||||||
padding-right: .5em;
|
|
||||||
border-right: 1px solid var(--padding-color);
|
|
||||||
background: var(--optional-channel-list-background);
|
|
||||||
background-color: var(--sidebar-background-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
#members-container {
|
#members-container {
|
||||||
min-width: 15rem;
|
|
||||||
max-width: 15rem;
|
|
||||||
border-left: 1px solid var(--padding-color);
|
|
||||||
background: var(--optional-member-list-background);
|
background: var(--optional-member-list-background);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,12 +130,14 @@ function handleMemberClick(member: GuildMemberResponse) {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: .5em;
|
gap: .5em;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.member-avatar {
|
.member-avatar {
|
||||||
height: 2.3em;
|
min-width: 2.3em;
|
||||||
width: 2.3em;
|
max-width: 2.3em;
|
||||||
border-radius: 50%;
|
min-width: 2.3em;
|
||||||
|
max-height: 2.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.member-display-name {
|
.member-display-name {
|
||||||
|
@ -151,6 +155,8 @@ function handleMemberClick(member: GuildMemberResponse) {
|
||||||
|
|
||||||
#server-name {
|
#server-name {
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
#server-settings-button {
|
#server-settings-button {
|
||||||
|
|
|
@ -46,9 +46,13 @@
|
||||||
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { Profile, Account, Privacy, Devices, Connections } from '~/components/Settings/UserSettings';
|
||||||
|
import { Appearance, Notifications, Keybinds, Language } from '~/components/Settings/AppSettings';
|
||||||
|
|
||||||
import VerticalSpacer from '~/components/UserInterface/VerticalSpacer.vue';
|
import VerticalSpacer from '~/components/UserInterface/VerticalSpacer.vue';
|
||||||
import Button from '~/components/UserInterface/Button.vue';
|
import Button from '~/components/UserInterface/Button.vue';
|
||||||
|
|
||||||
|
|
||||||
const { logout } = useAuth()
|
const { logout } = useAuth()
|
||||||
const appConfig = useRuntimeConfig()
|
const appConfig = useRuntimeConfig()
|
||||||
|
|
||||||
|
@ -62,17 +66,6 @@ interface Category {
|
||||||
pages: Page[];
|
pages: Page[];
|
||||||
}
|
}
|
||||||
|
|
||||||
import Profile from '~/components/Settings/UserSettings/Profile.vue';
|
|
||||||
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 = {
|
const settingsCategories = {
|
||||||
userSettings: {
|
userSettings: {
|
||||||
displayName: "User Settings",
|
displayName: "User Settings",
|
||||||
|
|
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
|
@ -47,6 +47,9 @@ importers:
|
||||||
vue-router:
|
vue-router:
|
||||||
specifier: ^4.5.1
|
specifier: ^4.5.1
|
||||||
version: 4.5.1(vue@3.5.13(typescript@5.8.3))
|
version: 4.5.1(vue@3.5.13(typescript@5.8.3))
|
||||||
|
xxhash-wasm:
|
||||||
|
specifier: ^1.1.0
|
||||||
|
version: 1.1.0
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@iconify-json/lucide':
|
'@iconify-json/lucide':
|
||||||
specifier: ^1.2.44
|
specifier: ^1.2.44
|
||||||
|
@ -4744,6 +4747,9 @@ packages:
|
||||||
engines: {node: '>= 0.10.0'}
|
engines: {node: '>= 0.10.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
xxhash-wasm@1.1.0:
|
||||||
|
resolution: {integrity: sha512-147y/6YNh+tlp6nd/2pWq38i9h6mz/EuQ6njIrmW8D1BS5nCqs0P6DG+m6zTGnNz5I+uhZ0SHxBs9BsPrwcKDA==}
|
||||||
|
|
||||||
y18n@5.0.8:
|
y18n@5.0.8:
|
||||||
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
|
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
|
||||||
engines: {node: '>=10'}
|
engines: {node: '>=10'}
|
||||||
|
@ -10146,6 +10152,8 @@ snapshots:
|
||||||
cssfilter: 0.0.10
|
cssfilter: 0.0.10
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
xxhash-wasm@1.1.0: {}
|
||||||
|
|
||||||
y18n@5.0.8: {}
|
y18n@5.0.8: {}
|
||||||
|
|
||||||
yallist@3.1.1: {}
|
yallist@3.1.1: {}
|
||||||
|
|
|
@ -11,11 +11,18 @@
|
||||||
--chatbox-background-color: #3a3733;
|
--chatbox-background-color: #3a3733;
|
||||||
|
|
||||||
--padding-color: #e0e0e0;
|
--padding-color: #e0e0e0;
|
||||||
|
|
||||||
--primary-color: #f07028;
|
--primary-color: #f07028;
|
||||||
--primary-highlighted-color: #f28f4b;
|
--primary-highlighted-color: #f28f4b;
|
||||||
--secondary-color: #683820;
|
--secondary-color: #683820;
|
||||||
--secondary-highlighted-color: #885830;
|
--secondary-highlighted-color: #885830;
|
||||||
--accent-color: #a04b24;
|
--accent-color: #a04b24;
|
||||||
--accent-highlighted-color: #b86038;
|
--accent-highlighted-color: #b86038;
|
||||||
|
|
||||||
|
--sidebar-width: 2.5em;
|
||||||
|
--standard-radius: .5em;
|
||||||
|
--button-radius: .6em;
|
||||||
|
--guild-icon-radius: 20%;
|
||||||
|
--pfp-radius: 50%;
|
||||||
|
--preferred-font: Arial;
|
||||||
}
|
}
|
|
@ -18,4 +18,14 @@
|
||||||
--secondary-highlighted-color: #8f5b2c;
|
--secondary-highlighted-color: #8f5b2c;
|
||||||
--accent-color: #b35719;
|
--accent-color: #b35719;
|
||||||
--accent-highlighted-color: #c76a2e;
|
--accent-highlighted-color: #c76a2e;
|
||||||
|
|
||||||
|
--sidebar-icon-width: 2.5em;
|
||||||
|
--sidebar-icon-gap: .25em;
|
||||||
|
--sidebar-margin: .5em;
|
||||||
|
|
||||||
|
--standard-radius: .5em;
|
||||||
|
--button-radius: .6em;
|
||||||
|
--guild-icon-radius: 15%;
|
||||||
|
--pfp-radius: 50%;
|
||||||
|
--preferred-font: Arial;
|
||||||
}
|
}
|
|
@ -20,6 +20,12 @@
|
||||||
--accent-color: #ff218c80;
|
--accent-color: #ff218c80;
|
||||||
--accent-highlighted-color: #df1b6f80;
|
--accent-highlighted-color: #df1b6f80;
|
||||||
|
|
||||||
|
--sidebar-width: 2.5em;
|
||||||
|
--standard-radius: .5em;
|
||||||
|
--button-radius: .6em;
|
||||||
|
--pfp-radius: 50%;
|
||||||
|
--preferred-font: Arial;
|
||||||
|
|
||||||
--optional-body-background: ; /* background element for the body */
|
--optional-body-background: ; /* background element for the body */
|
||||||
--optional-chat-background: ; /* background element for the chat box */
|
--optional-chat-background: ; /* background element for the chat box */
|
||||||
--optional-topbar-background: ; /* background element for the topbar */
|
--optional-topbar-background: ; /* background element for the topbar */
|
||||||
|
|
|
@ -18,4 +18,10 @@
|
||||||
--secondary-highlighted-color: #f8b68a;
|
--secondary-highlighted-color: #f8b68a;
|
||||||
--accent-color: #e68b4e;
|
--accent-color: #e68b4e;
|
||||||
--accent-highlighted-color: #f69254;
|
--accent-highlighted-color: #f69254;
|
||||||
|
|
||||||
|
--sidebar-width: 2.5em;
|
||||||
|
--standard-radius: .5em;
|
||||||
|
--button-radius: .6em;
|
||||||
|
--pfp-radius: 50%;
|
||||||
|
--preferred-font: Arial;
|
||||||
}
|
}
|
|
@ -19,6 +19,12 @@
|
||||||
--accent-color: #ff218c80;
|
--accent-color: #ff218c80;
|
||||||
--accent-highlighted-color: #df1b6f80;
|
--accent-highlighted-color: #df1b6f80;
|
||||||
|
|
||||||
|
--sidebar-width: 2.5em;
|
||||||
|
--standard-radius: .5em;
|
||||||
|
--button-radius: .6em;
|
||||||
|
--pfp-radius: 50%;
|
||||||
|
--preferred-font: Arial;
|
||||||
|
|
||||||
/* --optional-body-background: background */
|
/* --optional-body-background: background */
|
||||||
--optional-body-background: linear-gradient(45deg, #ed222480, #ed222480, #ed222480, #ed222480, #ed222480, #ed222480, #f35b2280, #f9962180, #f5c11e80, #f1eb1b80, #f1eb1b80, #f1eb1b80, #63c72080, #0c9b4980, #21878d80, #3954a580, #61379b80, #93288e80);
|
--optional-body-background: linear-gradient(45deg, #ed222480, #ed222480, #ed222480, #ed222480, #ed222480, #ed222480, #f35b2280, #f9962180, #f5c11e80, #f1eb1b80, #f1eb1b80, #f1eb1b80, #63c72080, #0c9b4980, #21878d80, #3954a580, #61379b80, #93288e80);
|
||||||
--optional-topbar-background: linear-gradient(-12.5deg, cyan, pink, white, pink, cyan);
|
--optional-topbar-background: linear-gradient(-12.5deg, cyan, pink, white, pink, cyan);
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import type { RuntimeNuxtHooks } from 'nuxt/schema';
|
|
||||||
|
|
||||||
declare module "nuxt/schema" {
|
declare module "nuxt/schema" {
|
||||||
interface RuntimeNuxtHooks {
|
interface RuntimeNuxtHooks {
|
||||||
"app:message:right-clicked": (payload: { messageId: string }) => void
|
"app:message:right-clicked": (payload: { messageId: string }) => void
|
||||||
|
|
|
@ -3,12 +3,13 @@ import type { MessageResponse, UserResponse } from "./interfaces";
|
||||||
export interface MessageProps {
|
export interface MessageProps {
|
||||||
class?: string,
|
class?: string,
|
||||||
img?: string | null,
|
img?: string | null,
|
||||||
author?: UserResponse
|
author: UserResponse
|
||||||
text: string,
|
text: string,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
format: "12" | "24",
|
format: "12" | "24",
|
||||||
type: "normal" | "grouped",
|
type: "normal" | "grouped",
|
||||||
marginBottom: boolean,
|
marginBottom: boolean,
|
||||||
|
authorColor: string,
|
||||||
last: boolean,
|
last: boolean,
|
||||||
messageId: string,
|
messageId: string,
|
||||||
replyingTo?: boolean,
|
replyingTo?: boolean,
|
||||||
|
|
|
@ -2,15 +2,19 @@ import { render } from "vue";
|
||||||
import ContextMenu from "~/components/UserInterface/ContextMenu.vue";
|
import ContextMenu from "~/components/UserInterface/ContextMenu.vue";
|
||||||
import type { ContextMenuItem } from "~/types/interfaces";
|
import type { ContextMenuItem } from "~/types/interfaces";
|
||||||
|
|
||||||
export default (e: MouseEvent, menuItems: ContextMenuItem[]) => {
|
export default (e: PointerEvent | MouseEvent, menuItems: ContextMenuItem[]) => {
|
||||||
console.log("Rendering new context menu");
|
console.log("Rendering new context menu");
|
||||||
const menuContainer = document.createElement("div");
|
const menuContainer = document.createElement("div");
|
||||||
|
console.log("hello");
|
||||||
menuContainer.id = "context-menu";
|
menuContainer.id = "context-menu";
|
||||||
document.body.appendChild(menuContainer);
|
document.body.appendChild(menuContainer);
|
||||||
|
console.log("pointer x:", e.clientX);
|
||||||
|
console.log("pointer y:", e.clientY);
|
||||||
|
console.log("menu items:", menuItems);
|
||||||
const contextMenu = h(ContextMenu, {
|
const contextMenu = h(ContextMenu, {
|
||||||
menuItems,
|
menuItems,
|
||||||
cursorX: e.clientX,
|
pointerX: e.clientX,
|
||||||
cursorY: e.clientY
|
pointerY: e.clientY
|
||||||
});
|
});
|
||||||
render(contextMenu, menuContainer);
|
render(contextMenu, menuContainer);
|
||||||
console.log("Rendered");
|
console.log("Rendered");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { NitroFetchRequest, NitroFetchOptions } from "nitropack";
|
import type { NitroFetchOptions } from "nitropack";
|
||||||
|
|
||||||
export default async <T>(path: string, options: NitroFetchOptions<string> = {}) => {
|
export default async <T>(path: string, options: NitroFetchOptions<string> = {}) => {
|
||||||
console.log("path received:", path);
|
console.log("path received:", path);
|
||||||
|
|
38
utils/generateDefaultIcon.ts
Normal file
38
utils/generateDefaultIcon.ts
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
export default (name: string, seed: string): string => {
|
||||||
|
const canvas = document.createElement("canvas");
|
||||||
|
const ctx = canvas.getContext("2d");
|
||||||
|
if (canvas && ctx) {
|
||||||
|
canvas.width = 256;
|
||||||
|
canvas.height = 256;
|
||||||
|
|
||||||
|
// get the first char from every word in the guild name
|
||||||
|
let previewName = "";
|
||||||
|
if (name.length > 3) {
|
||||||
|
let guildName: string[] = name.split(' ')
|
||||||
|
for (let i = 0; i < 3; i ++) {
|
||||||
|
if (guildName.length > i) {
|
||||||
|
previewName += guildName[i].charAt(0)
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
previewName = name
|
||||||
|
}
|
||||||
|
|
||||||
|
// fill background using seeded colour
|
||||||
|
ctx.fillStyle = generateIrcColor(seed, 50)
|
||||||
|
ctx.fillRect(0, 0, 256, 256)
|
||||||
|
|
||||||
|
ctx.fillStyle = 'white'
|
||||||
|
ctx.textAlign = 'center'
|
||||||
|
ctx.textBaseline = 'middle'
|
||||||
|
ctx.font = `bold 96px Arial, Helvetica, sans-serif`
|
||||||
|
// 136 isn't actually centered, but it *looks* centered
|
||||||
|
ctx.fillText(previewName, 128, 136)
|
||||||
|
|
||||||
|
return canvas.toDataURL("image/png");
|
||||||
|
}
|
||||||
|
|
||||||
|
return "https://tenor.com/view/dame-da-ne-guy-kiryukazuma-kiryu-yakuza-yakuza-0-gif-14355451116903905918"
|
||||||
|
}
|
13
utils/generateIrcColor.ts
Normal file
13
utils/generateIrcColor.ts
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import xxhash from "xxhash-wasm"
|
||||||
|
|
||||||
|
let h64: CallableFunction;
|
||||||
|
(async () => {
|
||||||
|
h64 = (await xxhash()).h64;
|
||||||
|
})();
|
||||||
|
|
||||||
|
export default (seed: string, saturation: number = 100, lightness: number = 50): string => {
|
||||||
|
const idHash = useState(`h64Hash-${seed}`, () => h64(seed))
|
||||||
|
const hashValue: bigint = idHash.value
|
||||||
|
|
||||||
|
return `hsl(${hashValue % 360n}, ${saturation}%, ${lightness}%)`
|
||||||
|
}
|
7
utils/getDisplayName.ts
Normal file
7
utils/getDisplayName.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import type { GuildMemberResponse, UserResponse } from "~/types/interfaces";
|
||||||
|
|
||||||
|
export default (user: UserResponse, member?: GuildMemberResponse): string => {
|
||||||
|
if (member?.nickname) return member.nickname
|
||||||
|
if (user.display_name) return user.display_name
|
||||||
|
return user.username
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
export async function hashPassword(password: string) {
|
export default async (password: string) => {
|
||||||
const encodedPass = new TextEncoder().encode(password);
|
const encodedPass = new TextEncoder().encode(password);
|
||||||
const hashBuffer = await crypto.subtle.digest("SHA-384", encodedPass);
|
const hashBuffer = await crypto.subtle.digest("SHA-384", encodedPass);
|
||||||
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
50
utils/isCanvasBlocked.ts
Normal file
50
utils/isCanvasBlocked.ts
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
//
|
||||||
|
// Canvas Blocker &
|
||||||
|
// Firefox privacy.resistFingerprinting Detector.
|
||||||
|
// (c) 2018 // JOHN OZBAY // CRYPT.EE
|
||||||
|
// MIT License
|
||||||
|
//
|
||||||
|
export default () => {
|
||||||
|
// create a 1px image data
|
||||||
|
var blocked = false;
|
||||||
|
var canvas = document.createElement("canvas");
|
||||||
|
var ctx = canvas.getContext("2d");
|
||||||
|
|
||||||
|
// some blockers just return an undefined ctx. So let's check that first.
|
||||||
|
if (ctx) {
|
||||||
|
var imageData = ctx.createImageData(1,1);
|
||||||
|
var originalImageData = imageData.data;
|
||||||
|
|
||||||
|
// set pixels to RGB 128
|
||||||
|
originalImageData[0]=128;
|
||||||
|
originalImageData[1]=128;
|
||||||
|
originalImageData[2]=128;
|
||||||
|
originalImageData[3]=255;
|
||||||
|
|
||||||
|
// set this to canvas
|
||||||
|
ctx.putImageData(imageData,1,1);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// now get the data back from canvas.
|
||||||
|
var checkData = ctx.getImageData(1, 1, 1, 1).data;
|
||||||
|
|
||||||
|
// If this is firefox, and privacy.resistFingerprinting is enabled,
|
||||||
|
// OR a browser extension blocking the canvas,
|
||||||
|
// This will return RGB all white (255,255,255) instead of the (128,128,128) we put.
|
||||||
|
|
||||||
|
// so let's check the R and G to see if they're 255 or 128 (matching what we've initially set)
|
||||||
|
if (originalImageData[0] !== checkData[0] && originalImageData[1] !== checkData[1]) {
|
||||||
|
blocked = true;
|
||||||
|
console.log("Canvas is blocked. Will display warning.");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// some extensions will return getImageData null. this is to account for that.
|
||||||
|
blocked = true;
|
||||||
|
console.log("Canvas is blocked. Will display warning.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
blocked = true;
|
||||||
|
console.log("Canvas is blocked. Will display warning.");
|
||||||
|
}
|
||||||
|
return blocked;
|
||||||
|
}
|
28
utils/loadPreferredTheme.ts
Normal file
28
utils/loadPreferredTheme.ts
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
let themeLinkElement: HTMLLinkElement | null;
|
||||||
|
|
||||||
|
export default function loadPreferredTheme() {
|
||||||
|
const currentTheme = settingsLoad().selectedThemeId ?? "dark"
|
||||||
|
|
||||||
|
if (themeLinkElement) {
|
||||||
|
themeLinkElement.href = getThemeUrl(currentTheme);
|
||||||
|
} else {
|
||||||
|
// create the theme link if one doesn't already exist
|
||||||
|
useHead({
|
||||||
|
link: [{
|
||||||
|
id: "main-theme",
|
||||||
|
rel: "stylesheet",
|
||||||
|
href: getThemeUrl(currentTheme)
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
themeLinkElement = document.getElementById('main-theme') as HTMLLinkElement;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getThemeUrl(id: string): string {
|
||||||
|
const runtimeConfig = useRuntimeConfig()
|
||||||
|
const baseURL = runtimeConfig.app.baseURL;
|
||||||
|
|
||||||
|
// this should preferrably use version hash, but that's not implemented yet
|
||||||
|
return `${baseURL}themes/${id}.css?v=${runtimeConfig.public.buildTimeString}`
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ export default (element: HTMLDivElement, props: MessageProps) => {
|
||||||
const messageBox = document.getElementById("message-box") as HTMLDivElement;
|
const messageBox = document.getElementById("message-box") as HTMLDivElement;
|
||||||
if (messageBox) {
|
if (messageBox) {
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
const messageReply = h(MessageReply, { author: props.author?.display_name || props.author!.username, text: props.text || "", id: props.message.uuid, replyId: props.replyMessage?.uuid || element.dataset.messageId!, maxWidth: "full" });
|
const messageReply = h(MessageReply, { author: getDisplayName(props.author), text: props.text || "", id: props.message.uuid, replyId: props.replyMessage?.uuid || element.dataset.messageId!, maxWidth: "full" });
|
||||||
messageBox.prepend(div);
|
messageBox.prepend(div);
|
||||||
render(messageReply, div);
|
render(messageReply, div);
|
||||||
}
|
}
|
||||||
|
|
7
utils/sortMembers.ts
Normal file
7
utils/sortMembers.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import type { GuildMemberResponse } from "~/types/interfaces";
|
||||||
|
|
||||||
|
export default (members: GuildMemberResponse[]): GuildMemberResponse[] => {
|
||||||
|
return members.sort((a, b) => {
|
||||||
|
return getDisplayName(a.user, a).localeCompare(getDisplayName(b.user, b))
|
||||||
|
})
|
||||||
|
}
|
7
utils/sortUsers.ts
Normal file
7
utils/sortUsers.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import type { UserResponse } from "~/types/interfaces";
|
||||||
|
|
||||||
|
export default (users: UserResponse[]): UserResponse[] => {
|
||||||
|
return users.sort((a, b) => {
|
||||||
|
return getDisplayName(a).localeCompare(getDisplayName(b))
|
||||||
|
})
|
||||||
|
}
|
3
utils/validateUsername.ts
Normal file
3
utils/validateUsername.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default (username: string) => {
|
||||||
|
return /^[\w.-]+$/.test(username);
|
||||||
|
}
|
|
@ -1,3 +0,0 @@
|
||||||
export function validateUsername(username: string) {
|
|
||||||
return /^[\w.-]+$/.test(username);
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue