Compare commits
2 commits
main
...
server-sid
Author | SHA1 | Date | |
---|---|---|---|
df550b561a | |||
8101c83825 |
71 changed files with 611 additions and 1720 deletions
|
@ -8,6 +8,7 @@ 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
|
||||||
|
|
38
app.vue
38
app.vue
|
@ -1,33 +1,25 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<Banner v-if="banner" />
|
<Banner v-if="banner" />
|
||||||
<ContextMenu v-if="contextMenu && contextMenu.show" :pointer-x="contextMenu.pointerX" :pointer-y="contextMenu.pointerY" :menu-items="contextMenu.items" />
|
<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 type { ContextMenuInterface } from './types/interfaces';
|
|
||||||
|
|
||||||
const banner = useState("banner", () => false);
|
const banner = useState("banner", () => false);
|
||||||
|
|
||||||
const contextMenu = useState<ContextMenuInterface>("contextMenu");
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadPreferredThemes()
|
|
||||||
|
|
||||||
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;
|
if (e.target instanceof Element && e.target.classList.contains("default-contextmenu")) return;
|
||||||
contextMenuHandler(e);
|
contextMenuHandler(e);
|
||||||
});
|
});
|
||||||
document.addEventListener("mousedown", (e) => {
|
document.addEventListener("mousedown", (e) => {
|
||||||
if (e.target instanceof HTMLElement && e.target.closest("#context-menu")) return;
|
if (e.target instanceof HTMLDivElement && e.target.closest("#context-menu")) return;
|
||||||
console.log("click");
|
console.log("click");
|
||||||
console.log("target:", e.target);
|
console.log("target:", e.target);
|
||||||
console.log(e.target instanceof HTMLDivElement);
|
console.log(e.target instanceof HTMLDivElement);
|
||||||
removeContextMenu(contextMenu);
|
removeContextMenu();
|
||||||
if (e.target instanceof HTMLElement && e.target.classList.contains("message-text") && e.target.contentEditable) {
|
if (e.target instanceof HTMLElement && e.target.classList.contains("message-text") && e.target.contentEditable) {
|
||||||
e.target.contentEditable = "false";
|
e.target.contentEditable = "false";
|
||||||
}
|
}
|
||||||
|
@ -44,10 +36,6 @@ onMounted(() => {
|
||||||
if (e.key == "Escape" && messageReply) {
|
if (e.key == "Escape" && messageReply) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
messageReply.remove();
|
messageReply.remove();
|
||||||
const replyToMessage = document.querySelector(`.message[data-message-id='${messageReply.dataset.messageId}']`);
|
|
||||||
if (replyToMessage) {
|
|
||||||
replyToMessage.classList.remove("replying-to");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -60,13 +48,19 @@ 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: var(--preferred-font), Arial, Helvetica, sans-serif;
|
font-family: var(--preferred-font), Arial, Helvetica, sans-serif;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
|
@ -12,4 +12,8 @@ export default class Message {
|
||||||
this.userUuid = user_uuid;
|
this.userUuid = user_uuid;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTimestamp() {
|
||||||
|
return uuidToTimestamp(this.uuid);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -3,10 +3,8 @@
|
||||||
class="display-avatar"
|
class="display-avatar"
|
||||||
:src="displayAvatar"
|
:src="displayAvatar"
|
||||||
:alt="displayName" />
|
:alt="displayName" />
|
||||||
<DefaultIcon v-else
|
<Icon v-else
|
||||||
class="display-avatar"
|
name="lucide:user"
|
||||||
:name="displayName"
|
|
||||||
:seed="user.uuid"
|
|
||||||
:alt="displayName" />
|
:alt="displayName" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -14,24 +12,27 @@
|
||||||
import { NuxtImg } from '#components';
|
import { NuxtImg } from '#components';
|
||||||
import type { GuildMemberResponse, UserResponse } from '~/types/interfaces';
|
import type { GuildMemberResponse, UserResponse } from '~/types/interfaces';
|
||||||
|
|
||||||
const { getDisplayName } = useProfile()
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
profile: UserResponse | GuildMemberResponse,
|
user?: UserResponse,
|
||||||
|
member?: GuildMemberResponse,
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const displayName = getDisplayName(props.profile)
|
|
||||||
let user: UserResponse
|
let displayName: string
|
||||||
let displayAvatar: string | null
|
let displayAvatar: string | null
|
||||||
|
|
||||||
if ("username" in props.profile) {
|
const user = props.user || props.member?.user
|
||||||
// assume it's a UserResponse
|
|
||||||
displayAvatar = props.profile.avatar
|
if (user) {
|
||||||
user = props.profile
|
displayName = getDisplayName(user, props.member)
|
||||||
} else {
|
|
||||||
// assume it's a GuildMemberResponse
|
if (user.avatar) {
|
||||||
displayAvatar = props.profile.user.avatar
|
displayAvatar = user.avatar
|
||||||
user = props.profile.user
|
} else if (!isCanvasBlocked()){
|
||||||
|
displayAvatar = generateDefaultIcon(displayName, user.uuid)
|
||||||
|
} else {
|
||||||
|
displayAvatar = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
<template>
|
|
||||||
<div :style="`background-color: ${generateIrcColor(seed, 50)}`"
|
|
||||||
class="default-icon">
|
|
||||||
<div class="default-icon-text-container">
|
|
||||||
<span class="default-icon-text">
|
|
||||||
{{ previewName }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
seed: string,
|
|
||||||
name: string
|
|
||||||
}>();
|
|
||||||
|
|
||||||
let previewName = "";
|
|
||||||
if (props.name.length > 3) {
|
|
||||||
let guildName: string[] = props.name.split(' ')
|
|
||||||
for (let i = 0; i < 3; i ++) {
|
|
||||||
if (guildName.length > i) {
|
|
||||||
previewName += guildName[i].charAt(0)
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
previewName = props.name
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.default-icon, .default-icon-text-container {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.default-icon-text-container {
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.default-icon-text {
|
|
||||||
/* helps centre the icon, yes, this is NOT perfect */
|
|
||||||
margin-top: -0.15em;
|
|
||||||
|
|
||||||
font-weight: bold;
|
|
||||||
|
|
||||||
color: var(--secondary-text-color)
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,10 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="isCurrentChannel" class="channel-list-link-container rounded-corners current-channel" tabindex="0" :title="props.name">
|
<div v-if="isCurrentChannel" class="channel-list-link-container rounded-corners current-channel" tabindex="0">
|
||||||
<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" :title="props.name">
|
<div v-else class="channel-list-link-container rounded-corners" tabindex="0">
|
||||||
<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,8 +25,6 @@ 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 {
|
||||||
|
|
|
@ -27,7 +27,7 @@ const props = defineProps<{ options: DropdownOption[] }>();
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-option {
|
.dropdown-option {
|
||||||
border: .09rem solid var(--padding-color);
|
border: .09rem solid rgb(70, 70, 70);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-button {
|
.dropdown-button {
|
||||||
|
|
|
@ -1,44 +1,33 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="member-item" @click.prevent="showModalPopup" tabindex="0">
|
<div class="member-item" @click="togglePopup" @blur="hidePopup" tabindex="0">
|
||||||
<Avatar :profile="props.member" class="member-avatar"/>
|
<Avatar :member="props.member" class="member-avatar"/>
|
||||||
<span class="member-display-name" :style="`color: ${generateIrcColor(props.member.user.uuid)}`">
|
<span class="member-display-name">{{ getDisplayName(props.member.user, props.member) }}</span>
|
||||||
{{ getDisplayName(props.member) }}
|
<UserPopup v-if="isPopupVisible" :user="props.member.user" id="profile-popup" />
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<ModalProfilePopup v-if="modalPopupVisible" :profile="props.member"
|
|
||||||
:onFinish="hideModalPopup" :keepalive="false"/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ModalProfilePopup } from '#components';
|
import { ref } from 'vue';
|
||||||
import type { GuildMemberResponse } from '~/types/interfaces';
|
import type { GuildMemberResponse } from '~/types/interfaces';
|
||||||
|
|
||||||
const { getDisplayName } = useProfile()
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
member: GuildMemberResponse
|
member: GuildMemberResponse
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const modalPopupVisible = ref<boolean>(false);
|
const isPopupVisible = ref(false);
|
||||||
|
|
||||||
function showModalPopup() {
|
const togglePopup = () => {
|
||||||
modalPopupVisible.value = true
|
isPopupVisible.value = false;
|
||||||
}
|
// isPopupVisible.value = !isPopupVisible.value;
|
||||||
|
};
|
||||||
|
|
||||||
function hideModalPopup() {
|
const hidePopup = () => {
|
||||||
modalPopupVisible.value = false
|
isPopupVisible.value = false;
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.member-item {
|
.member-item {
|
||||||
position: relative;
|
position: relative; /* Set the position to relative for absolute positioning of the popup */
|
||||||
}
|
|
||||||
|
|
||||||
.member-avatar {
|
|
||||||
min-height: 2.3em;
|
|
||||||
max-height: 2.3em;
|
|
||||||
min-width: 2.3em;
|
|
||||||
max-width: 2.3em;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -23,10 +23,8 @@ async function sendRequest() {
|
||||||
try {
|
try {
|
||||||
await addFriend(inputField.value.value)
|
await addFriend(inputField.value.value)
|
||||||
alert("Friend request sent!")
|
alert("Friend request sent!")
|
||||||
} catch (error: any) {
|
} catch {
|
||||||
if (error?.response?.status !== 200) {
|
alert("Request failed :(")
|
||||||
alert(`error ${error?.response?.status} met whilst trying to add friend\n"${error?.response._data?.message}"`)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,27 @@
|
||||||
<template>
|
<template>
|
||||||
<ResizableSidebar width="14rem" min-width="8rem" max-width="30rem" border-sides="right" local-storage-name="middleLeftColumn">
|
<div id="middle-left-column">
|
||||||
<div id="middle-left-column">
|
<div id="friend-sidebar">
|
||||||
<div id="friend-sidebar">
|
<div>
|
||||||
<div>
|
<h3>Direct Messages</h3>
|
||||||
<h3>Direct Messages</h3>
|
</div>
|
||||||
</div>
|
<VerticalSpacer />
|
||||||
<VerticalSpacer />
|
|
||||||
|
|
||||||
<NuxtLink class="user-item" :href="`/me`" tabindex="0">
|
<NuxtLink class="user-item" :href="`/me`" tabindex="0">
|
||||||
<Icon class="user-avatar" name="lucide:user" />
|
<Icon class="user-avatar" name="lucide:user" />
|
||||||
<span class="user-display-name">Friends</span>
|
<span class="user-display-name">Friends</span>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<VerticalSpacer />
|
<VerticalSpacer />
|
||||||
|
|
||||||
<div id="direct-message-list">
|
<div id="direct-message-list">
|
||||||
<UserEntry v-for="user of friends" :user="user"
|
<UserEntry v-for="user of friends" :user="user"
|
||||||
:href="`/me/${user.uuid}`"/>
|
:href="`/me/${user.uuid}`"/>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ResizableSidebar>
|
</div>
|
||||||
</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();
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,11 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|
||||||
const { getDisplayName } = useProfile()
|
|
||||||
const { fetchFriends } = useApi();
|
const { fetchFriends } = useApi();
|
||||||
|
|
||||||
const friends = sortUsers(await fetchFriends())
|
const friends = await fetchFriends().then((response) => {
|
||||||
|
return response.sort((a, b) => getDisplayName(a).localeCompare(getDisplayName(b)))
|
||||||
|
})
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
variant: string
|
variant: string
|
||||||
|
|
|
@ -1,62 +1,64 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="props.type == 'normal' || props.replyMessage" ref="messageElement" @contextmenu="showContextMenu($event, contextMenu, menuItems)"
|
<div v-if="props.type == 'normal' || props.replyMessage" ref="messageElement" @contextmenu="createContextMenu($event, menuItems)" :id="props.last ? 'last-message' : undefined"
|
||||||
class="message normal-message" :class="{ 'highlighted': (props.isMentioned || (props.replyMessage && props.message.member.user.uuid != me!.uuid && props.replyMessage?.member.user.uuid == me!.uuid)) }"
|
class="message normal-message" :class="{ 'mentioned': (props.replyMessage || props.isMentioned) && props.message.user.uuid != props.me.uuid && props.replyMessage?.user.uuid == props.me.uuid }" :data-message-id="props.messageId"
|
||||||
:data-message-id="props.message.uuid" :editing.sync="props.editing">
|
: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" height="1.5em"
|
width="1.5em" height="1.5em"
|
||||||
viewBox="0 0 150 87.5" version="1.1" id="svg1"
|
viewBox="0 0 150 87.5" version="1.1" id="svg1"
|
||||||
style="overflow: visible;">
|
style="overflow: visible;">
|
||||||
<defs id="defs1" />
|
<defs id="defs1" />
|
||||||
<g id="layer1" transform="translate(40,-35)">
|
<g id="layer1"
|
||||||
<g id="g3" transform="translate(-35,-20)">
|
transform="translate(40,-35)">
|
||||||
|
<g id="g3"
|
||||||
|
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,87.5 100,2.5e-5"
|
d="m 120.02168,87.850978 100.76157,2.4e-5"
|
||||||
id="path3-5" />
|
id="path3-5" />
|
||||||
<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 70,150 120,87.5"
|
d="M 69.899501,174.963 120.2803,87.700931"
|
||||||
id="path3-5-2" />
|
id="path3-5-2" />
|
||||||
</g>
|
</g>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<MessageReply v-if="props.replyMessage" :id="props.message.uuid"
|
<MessageReply v-if="props.replyMessage" :id="props.message.uuid"
|
||||||
:author="getDisplayName(props.replyMessage.member)"
|
:author="getDisplayName(props.replyMessage.user)"
|
||||||
:text="props.replyMessage?.message"
|
:text="props.replyMessage?.message"
|
||||||
:reply-id="props.replyMessage.uuid" max-width="reply" />
|
:reply-id="props.replyMessage.uuid" max-width="reply" />
|
||||||
<div class="left-column">
|
<div class="left-column">
|
||||||
<Avatar :profile="props.message.member" class="message-author-avatar"/>
|
<Avatar :user="props.author" 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" :style="`color: ${generateIrcColor(props.message.member.user.uuid)}`">
|
<span class="message-author-username" tabindex="0" :style="`color: ${props.authorColor}`">
|
||||||
{{ getDisplayName(props.message.member) }}
|
{{ 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>
|
||||||
<span v-else-if="getDayDifference(date, currentDate) > 1 ">{{ date.toLocaleDateString(undefined) }},</span>
|
<span v-else-if="getDayDifference(date, currentDate) > 1 ">{{ date.toLocaleDateString(undefined) }},</span>
|
||||||
|
|
||||||
{{ date.toLocaleTimeString(undefined, { hour12: getPreferredTimeFormat() == "12", timeStyle: "short" }) }}
|
{{ date.toLocaleTimeString(undefined, { hour12: props.format == "12", timeStyle: "short" }) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="message-text" v-html="sanitized" :hidden="hideText" tabindex="0"></div>
|
<div class="message-text" v-html="sanitized" :hidden="hasEmbed" tabindex="0"></div>
|
||||||
<MessageMedia v-if="mediaLinks.length" :links="mediaLinks" />
|
|
||||||
</div>
|
</div>
|
||||||
|
<MessageMedia v-if="mediaLinks.length" :links="mediaLinks" />
|
||||||
</div>
|
</div>
|
||||||
<div v-else ref="messageElement" @contextmenu="showContextMenu($event, contextMenu, menuItems)"
|
<div v-else ref="messageElement" @contextmenu="createContextMenu($event, menuItems)" :id="props.last ? 'last-message' : undefined"
|
||||||
class="message grouped-message" :class="{ 'mentioned': props.replyMessage || props.isMentioned }"
|
class="message grouped-message" :class="{ 'message-margin-bottom': props.marginBottom, 'mentioned': props.replyMessage || props.isMentioned }"
|
||||||
:data-message-id="props.message.uuid" :editing.sync="props.editing">
|
:data-message-id="props.messageId" :editing.sync="props.editing" :replying-to.sync="props.replyingTo">
|
||||||
<div class="left-column">
|
<div class="left-column">
|
||||||
<span :class="{ 'invisible': dateHidden }" class="message-date side-message-date" :title="date.toString()">
|
<span :class="{ 'invisible': dateHidden }" class="message-date side-message-date" :title="date.toString()">
|
||||||
{{ date.toLocaleTimeString(undefined, { hour12: getPreferredTimeFormat() == "12", timeStyle: "short" }) }}
|
{{ date.toLocaleTimeString(undefined, { hour12: props.format == "12", timeStyle: "short" }) }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="message-data">
|
<div class="message-data">
|
||||||
<div class="message-text" :class="$style['message-text']" v-html="sanitized" :hidden="hideText" tabindex="0"></div>
|
<div class="message-text" :class="$style['message-text']" v-html="sanitized" :hidden="hasEmbed" tabindex="0"></div>
|
||||||
<MessageMedia v-if="mediaLinks.length" :links="mediaLinks"/>
|
|
||||||
</div>
|
</div>
|
||||||
|
<MessageMedia v-if="mediaLinks.length" :links="mediaLinks" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -66,40 +68,31 @@ import { parse } from 'marked';
|
||||||
import type { MessageProps } from '~/types/props';
|
import type { MessageProps } from '~/types/props';
|
||||||
import MessageMedia from './MessageMedia.vue';
|
import MessageMedia from './MessageMedia.vue';
|
||||||
import MessageReply from './UserInterface/MessageReply.vue';
|
import MessageReply from './UserInterface/MessageReply.vue';
|
||||||
import type { ContextMenuInterface, ContextMenuItem } from '~/types/interfaces';
|
|
||||||
|
|
||||||
const { getDisplayName } = useProfile()
|
|
||||||
const { getUser } = useAuth()
|
|
||||||
|
|
||||||
const props = defineProps<MessageProps>();
|
const props = defineProps<MessageProps>();
|
||||||
|
|
||||||
const me = await getUser()
|
|
||||||
|
|
||||||
const contextMenu = useState<ContextMenuInterface>("contextMenu", () => ({ show: false, pointerX: 0, pointerY: 0, items: [] }));
|
|
||||||
|
|
||||||
const messageElement = ref<HTMLDivElement>();
|
const messageElement = ref<HTMLDivElement>();
|
||||||
|
|
||||||
const dateHidden = ref<boolean>(true);
|
const dateHidden = ref<boolean>(true);
|
||||||
|
|
||||||
const date = uuidToDate(props.message.uuid);
|
const date = new Date(props.timestamp);
|
||||||
|
|
||||||
const currentDate: Date = new Date()
|
const currentDate: Date = new Date()
|
||||||
|
|
||||||
console.log("[MSG] message to render:", props.message);
|
console.log("[MSG] message to render:", props.message);
|
||||||
console.log("author:", props.message.member);
|
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 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 linkMatches = props.message.message.matchAll(linkRegex).map(link => link[0]);
|
||||||
const mediaLinks = ref<string[]>([]);
|
const mediaLinks: string[] = [];
|
||||||
console.log("link matches:", linkMatches);
|
console.log("link matches:", linkMatches);
|
||||||
|
|
||||||
const hideText = ref(false);
|
const hasEmbed = ref(false);
|
||||||
|
|
||||||
const sanitized = ref<string>();
|
const sanitized = ref<string>();
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const parsed = await parse(props.message.message, { gfm: true });
|
const parsed = await parse(props.text, { gfm: true });
|
||||||
sanitized.value = DOMPurify.sanitize(parsed, {
|
sanitized.value = DOMPurify.sanitize(parsed, {
|
||||||
ALLOWED_TAGS: [
|
ALLOWED_TAGS: [
|
||||||
"strong", "em", "br", "blockquote",
|
"strong", "em", "br", "blockquote",
|
||||||
|
@ -123,54 +116,39 @@ onMounted(async () => {
|
||||||
console.log("added listeners");
|
console.log("added listeners");
|
||||||
}
|
}
|
||||||
|
|
||||||
const links: string[] = [];
|
|
||||||
for (const link of linkMatches) {
|
for (const link of linkMatches) {
|
||||||
console.log("link:", link);
|
console.log("link:", link);
|
||||||
try {
|
try {
|
||||||
const res = await $fetch.raw(link);
|
const res = await $fetch.raw(link);
|
||||||
if (res.ok && res.headers.get("content-type")?.match(/^image\/(apng|gif|jpeg|png|webp)$/)) {
|
if (res.ok && res.headers.get("content-type")?.match(/^image\/(apng|gif|jpeg|png|webp)$/)) {
|
||||||
console.log("link is image");
|
console.log("link is image");
|
||||||
links.push(link);
|
mediaLinks.push(link);
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
}
|
||||||
|
if (mediaLinks.length) {
|
||||||
mediaLinks.value = [...links];
|
hasEmbed.value = true
|
||||||
|
setTimeout(() => {
|
||||||
|
scrollToBottom(document.getElementById("messages") as HTMLDivElement);
|
||||||
|
}, 500);
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mediaLinks.value.length) {
|
console.log("media links:", mediaLinks);
|
||||||
const nonLinks = props.message.message.split(linkRegex);
|
|
||||||
let invalidContent = false;
|
|
||||||
for (const nonLink of nonLinks) {
|
|
||||||
if (nonLink != "" && nonLink != "\n" && nonLink != "<br>") {
|
|
||||||
invalidContent = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hideText.value = !invalidContent;
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log("media links:", mediaLinks);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//function toggleTooltip(e: Event) {
|
//function toggleTooltip(e: Event) {
|
||||||
// showHover.value = !showHover.value;
|
// showHover.value = !showHover.value;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
const menuItems: ContextMenuItem[] = [
|
const menuItems = [
|
||||||
{ name: "Reply", icon: "lucide:reply", type: "normal", callback: () => { if (messageElement.value) replyToMessage(messageElement.value, props) } }
|
{ name: "Reply", callback: () => { if (messageElement.value) replyToMessage(messageElement.value, props) } }
|
||||||
]
|
]
|
||||||
|
|
||||||
console.log("me:", me);
|
console.log("me:", props.me);
|
||||||
if (props.message.member.user.uuid == me!.uuid) {
|
if (props.author?.uuid == props.me.uuid) {
|
||||||
// Inserts "edit" option at index 1 (below the "reply" option)
|
menuItems.push({ name: "Edit", callback: () => { if (messageElement.value) editMessage(messageElement.value, props) } });
|
||||||
menuItems.splice(1, 0, { name: "Edit (WIP)", icon: "lucide:square-pen", type: "normal", callback: () => { /* if (messageElement.value) editMessage(messageElement.value, props) */ } });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (props.message.member.user.uuid == me!.uuid /* || check message delete permission*/) {
|
|
||||||
// Inserts "edit" option at index 2 (below the "edit" option)
|
|
||||||
menuItems.splice(2, 0, { name: "Delete (WIP)", icon: "lucide:trash", type: "danger", callback: () => {} });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDayDifference(date1: Date, date2: Date) {
|
function getDayDifference(date1: Date, date2: Date) {
|
||||||
|
@ -188,20 +166,14 @@ function getDayDifference(date1: Date, date2: Date) {
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.message {
|
.message {
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 4rem 1fr;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
text-align: left;
|
text-align: left;
|
||||||
/* -4 dvw due to 2dvw of padding on both sides */
|
/* border: 1px solid lightcoral; */
|
||||||
width: calc(100% - 4dvw);
|
display: grid;
|
||||||
|
grid-template-columns: 2rem 1fr;
|
||||||
|
align-items: center;
|
||||||
|
column-gap: 1dvw;
|
||||||
|
width: 100%;
|
||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
|
|
||||||
padding-top: .2rem;
|
|
||||||
padding-bottom: .2rem;
|
|
||||||
padding-left: 2dvw;
|
|
||||||
padding-right: 1dvw;
|
|
||||||
border-radius: 0 var(--minor-radius) var(--minor-radius) 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-reply-preview {
|
.message-reply-preview {
|
||||||
|
@ -217,6 +189,14 @@ function getDayDifference(date1: Date, date2: Date) {
|
||||||
margin-top: 1dvh;
|
margin-top: 1dvh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.grouped-message {
|
||||||
|
margin-top: .3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#last-message {
|
||||||
|
margin-bottom: 2dvh;
|
||||||
|
}
|
||||||
|
|
||||||
.message-metadata {
|
.message-metadata {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: .5dvw;
|
gap: .5dvw;
|
||||||
|
@ -225,9 +205,10 @@ function getDayDifference(date1: Date, date2: Date) {
|
||||||
|
|
||||||
.message-data {
|
.message-data {
|
||||||
/* border: 1px solid white; */
|
/* border: 1px solid white; */
|
||||||
|
margin-left: .5dvw;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100%;
|
height: fit-content;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
grid-row: 2;
|
grid-row: 2;
|
||||||
grid-column: 2;
|
grid-column: 2;
|
||||||
|
@ -239,10 +220,7 @@ function getDayDifference(date1: Date, date2: Date) {
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-author-avatar {
|
.message-author-avatar {
|
||||||
min-height: 2.5em;
|
width: 100%;
|
||||||
max-height: 2.5em;
|
|
||||||
min-width: 2.5em;
|
|
||||||
max-width: 2.5em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-column {
|
.left-column {
|
||||||
|
@ -253,11 +231,8 @@ function getDayDifference(date1: Date, date2: Date) {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
grid-row: 2;
|
grid-row: 2;
|
||||||
grid-column: 1;
|
grid-column: 1;
|
||||||
height: 100%;
|
|
||||||
align-items: start;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.author-username {
|
.author-username {
|
||||||
margin-right: .5dvw;
|
margin-right: .5dvw;
|
||||||
color: white;
|
color: white;
|
||||||
|
@ -271,7 +246,9 @@ function getDayDifference(date1: Date, date2: Date) {
|
||||||
|
|
||||||
.side-message-date {
|
.side-message-date {
|
||||||
font-size: .625em;
|
font-size: .625em;
|
||||||
margin-top: .4em;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
align-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -281,12 +258,12 @@ function getDayDifference(date1: Date, date2: Date) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.highlighted {
|
.mentioned {
|
||||||
background-color: var(--chat-important-background-color);
|
background-color: rgba(0, 255, 166, 0.123);
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlighted:hover {
|
.mentioned:hover {
|
||||||
background-color: var(--chat-important-highlighted-background-color);
|
background-color: rgba(90, 255, 200, 0.233);
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-reply-svg {
|
.message-reply-svg {
|
||||||
|
@ -307,12 +284,3 @@ function getDayDifference(date1: Date, date2: Date) {
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style>
|
|
||||||
|
|
||||||
/* class used in utils/replyToMessage.ts */
|
|
||||||
.replying-to {
|
|
||||||
background-color: var(--chat-featured-message-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
<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" :key="message.uuid"
|
<Message v-for="(message, i) of messages" :username="getDisplayName(message.user)"
|
||||||
|
:text="message.message" :timestamp="messageTimestamps[message.uuid]" :img="message.user.avatar"
|
||||||
|
:format="timeFormat" :type="messagesType[message.uuid]"
|
||||||
|
: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"
|
||||||
:message="message" :is-reply="message.reply_to"
|
:message="message" :is-reply="message.reply_to"
|
||||||
:reply-message="message.reply_to ? getReplyMessage(message.reply_to) : undefined"
|
:author-color="`${generateIrcColor(message.user.uuid)}`"
|
||||||
:type="messagesType[message.uuid]"
|
:reply-message="message.reply_to ? getReplyMessage(message.reply_to) : undefined" />
|
||||||
:editing="false"
|
|
||||||
:is-mentioned="false" />
|
|
||||||
</div>
|
</div>
|
||||||
<div id="message-box" class="rounded-corners">
|
<div id="message-box" class="rounded-corners">
|
||||||
<form id="message-form" @submit="sendMessage">
|
<form id="message-form" @submit="sendMessage">
|
||||||
|
@ -42,12 +44,9 @@ import type { MessageResponse, ScrollPosition, UserResponse } from '~/types/inte
|
||||||
import scrollToBottom from '~/utils/scrollToBottom';
|
import scrollToBottom from '~/utils/scrollToBottom';
|
||||||
import { generateIrcColor } from '#imports';
|
import { generateIrcColor } from '#imports';
|
||||||
|
|
||||||
const { getDisplayName } = useProfile()
|
|
||||||
const { fetchMe } = useApi()
|
|
||||||
|
|
||||||
const props = defineProps<{ channelUrl: string, amount?: number, offset?: number }>();
|
const props = defineProps<{ channelUrl: string, amount?: number, offset?: number }>();
|
||||||
|
|
||||||
const me = await fetchMe() as UserResponse;
|
const me = await fetchWithApi("/me") as UserResponse;
|
||||||
|
|
||||||
const messageTimestamps = ref<Record<string, number>>({});
|
const messageTimestamps = ref<Record<string, number>>({});
|
||||||
const messagesType = ref<Record<string, "normal" | "grouped">>({});
|
const messagesType = ref<Record<string, "normal" | "grouped">>({});
|
||||||
|
@ -65,33 +64,33 @@ const previousMessage = ref<MessageResponse>();
|
||||||
function groupMessage(message: MessageResponse, options?: { prevMessage?: MessageResponse, reverse?: boolean }) {
|
function groupMessage(message: MessageResponse, options?: { prevMessage?: MessageResponse, reverse?: boolean }) {
|
||||||
messageTimestamps.value[message.uuid] = uuidToTimestamp(message.uuid);
|
messageTimestamps.value[message.uuid] = uuidToTimestamp(message.uuid);
|
||||||
console.log("message:", message.message);
|
console.log("message:", message.message);
|
||||||
console.log("author:", message.member.user.username, `(${message.member.uuid})`);
|
console.log("author:", message.user.username, `(${message.user.uuid})`);
|
||||||
|
|
||||||
if (!previousMessage.value || previousMessage.value && message.member.uuid != previousMessage.value.member.uuid) {
|
if (!previousMessage.value || previousMessage.value && message.user.uuid != previousMessage.value.user.uuid) {
|
||||||
console.log("no previous message or author is different than last messsage's");
|
console.log("no previous message or author is different than last messsage's");
|
||||||
messagesType.value[message.uuid] = "normal";
|
messagesType.value[message.uuid] = "normal";
|
||||||
previousMessage.value = message;
|
previousMessage.value = message;
|
||||||
console.log("set previous message to:", previousMessage.value.message);
|
console.log("set previous message to:", previousMessage.value.message);
|
||||||
console.log(`setting first post by user ${message.member.user.username} to "${message.message}" with timestamp ${messageTimestamps.value[message.uuid]}`);
|
console.log(`setting first post by user ${message.user.username} to "${message.message}" with timestamp ${messageTimestamps.value[message.uuid]}`);
|
||||||
firstMessageByUsers.value[message.member.uuid] = message;
|
firstMessageByUsers.value[message.user.uuid] = message;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const firstByUser = firstMessageByUsers.value[message.member.uuid];
|
const firstByUser = firstMessageByUsers.value[message.user.uuid];
|
||||||
if (firstByUser) {
|
if (firstByUser) {
|
||||||
console.log("first by user exists:", firstByUser);
|
console.log("first by user exists:", firstByUser);
|
||||||
if (message.member.uuid != firstByUser.member.uuid) {
|
if (message.user.uuid != firstByUser.user.uuid) {
|
||||||
console.log("message is by new user, setting their first message")
|
console.log("message is by new user, setting their first message")
|
||||||
firstMessageByUsers.value[message.member.uuid] = message;
|
firstMessageByUsers.value[message.user.uuid] = message;
|
||||||
console.log("RETURNING FALSE");
|
console.log("RETURNING FALSE");
|
||||||
messagesType.value[message.uuid] = "normal";
|
messagesType.value[message.uuid] = "normal";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("first by user doesn't exist");
|
console.log("first by user doesn't exist");
|
||||||
console.log(`setting first post by user ${message.member.user.username} to "${message.message}" with timestamp ${messageTimestamps.value[message.uuid]}`);
|
console.log(`setting first post by user ${message.user.username} to "${message.message}" with timestamp ${messageTimestamps.value[message.uuid]}`);
|
||||||
firstMessageByUsers.value[message.member.uuid] = message;
|
firstMessageByUsers.value[message.user.uuid] = message;
|
||||||
console.log("RETURNING FALSE");
|
console.log("RETURNING FALSE");
|
||||||
messagesType.value[message.uuid] = "normal";
|
messagesType.value[message.uuid] = "normal";
|
||||||
return;
|
return;
|
||||||
|
@ -109,8 +108,8 @@ function groupMessage(message: MessageResponse, options?: { prevMessage?: Messag
|
||||||
console.log("group?", lessThanMax);
|
console.log("group?", lessThanMax);
|
||||||
if (!lessThanMax) {
|
if (!lessThanMax) {
|
||||||
console.log("diff exceeds max");
|
console.log("diff exceeds max");
|
||||||
console.log(`setting first post by user ${message.member.user.username} to "${message.message}" with timestamp ${messageTimestamps.value[message.uuid]}`)
|
console.log(`setting first post by user ${message.user.username} to "${message.message}" with timestamp ${messageTimestamps.value[message.uuid]}`)
|
||||||
firstMessageByUsers.value[message.member.uuid] = message;
|
firstMessageByUsers.value[message.user.uuid] = message;
|
||||||
messagesType.value[message.uuid] = "normal";
|
messagesType.value[message.uuid] = "normal";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -222,10 +221,6 @@ function sendMessage(e: Event) {
|
||||||
if (messageReply && messageReply.dataset.messageId) {
|
if (messageReply && messageReply.dataset.messageId) {
|
||||||
console.log("[MSG] message is a reply");
|
console.log("[MSG] message is a reply");
|
||||||
message.reply_to = messageReply.dataset.messageId;
|
message.reply_to = messageReply.dataset.messageId;
|
||||||
const replyToMessage = document.querySelector(`.message[data-message-id='${message.reply_to}']`);
|
|
||||||
if (replyToMessage) {
|
|
||||||
replyToMessage.classList.remove("replying-to");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("[MSG] sent message:", message);
|
console.log("[MSG] sent message:", message);
|
||||||
|
@ -242,8 +237,12 @@ function sendMessage(e: Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getReplyMessage(id: string) {
|
function getReplyMessage(id: string) {
|
||||||
|
console.log("[REPLYMSG] id:", id);
|
||||||
const messagesValues = Object.values(messages.value);
|
const messagesValues = Object.values(messages.value);
|
||||||
|
console.log("[REPLYMSG] messages values:", messagesValues);
|
||||||
for (const message of messagesValues) {
|
for (const message of messagesValues) {
|
||||||
|
console.log("[REPLYMSG] message:", message);
|
||||||
|
console.log("[REPLYMSG] IDs match?", message.uuid == id);
|
||||||
if (message.uuid == id) return message;
|
if (message.uuid == id) return message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,14 +266,21 @@ onMounted(async () => {
|
||||||
if (fetched) return;
|
if (fetched) return;
|
||||||
fetched = true;
|
fetched = true;
|
||||||
console.log("scroll height is at 10% or less");
|
console.log("scroll height is at 10% or less");
|
||||||
|
//console.log("current oldest:", currentOldestMessage);
|
||||||
const olderMessages = await fetchMessages(route.params.channelId as string, { amount, offset });
|
const olderMessages = await fetchMessages(route.params.channelId as string, { amount, offset });
|
||||||
if (olderMessages?.length) {
|
if (olderMessages) {
|
||||||
olderMessages.reverse();
|
olderMessages.reverse();
|
||||||
messages.value = [...olderMessages.map(msg => reactive(msg)), ...messages.value];
|
console.log("older messages:", olderMessages);
|
||||||
for (const message of messages.value) {
|
if (olderMessages.length == 0) return;
|
||||||
groupMessage(message);
|
olderMessages.reverse();
|
||||||
|
for (const [i, oldMessage] of olderMessages.entries()) {
|
||||||
|
console.log("old message:", oldMessage);
|
||||||
|
messages.value.unshift(oldMessage);
|
||||||
|
for (const message of messages.value) {
|
||||||
|
groupMessage(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
offset += amount;
|
offset += offset;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fetched = false;
|
fetched = false;
|
||||||
|
@ -318,6 +324,8 @@ router.beforeEach((to, from, next) => {
|
||||||
#message-area {
|
#message-area {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
padding-left: 1dvw;
|
||||||
|
padding-right: 1dvw;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
@ -325,8 +333,8 @@ router.beforeEach((to, from, next) => {
|
||||||
#message-box {
|
#message-box {
|
||||||
margin-top: auto; /* force it to the bottom of the screen */
|
margin-top: auto; /* force it to the bottom of the screen */
|
||||||
margin-bottom: 2dvh;
|
margin-bottom: 2dvh;
|
||||||
margin-left: 2dvw;
|
margin-left: 1dvw;
|
||||||
margin-right: 2dvw;
|
margin-right: 1dvw;
|
||||||
|
|
||||||
padding-left: 2%;
|
padding-left: 2%;
|
||||||
padding-right: 2%;
|
padding-right: 2%;
|
||||||
|
@ -378,7 +386,8 @@ router.beforeEach((to, from, next) => {
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding-bottom: 1em;
|
padding-left: 1dvw;
|
||||||
|
padding-right: 1dvw;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message-box-button {
|
.message-box-button {
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="media-container">
|
<div class="media-container">
|
||||||
<NuxtImg v-for="link of props.links"
|
<NuxtImg v-for="link of props.links" class="media-item" :src="link" @click.prevent="createModal(link)" />
|
||||||
class="media-item"
|
|
||||||
:src="link"
|
|
||||||
@click.prevent="createModal(link)" />
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -11,6 +8,7 @@
|
||||||
import { ModalBase } from '#components';
|
import { ModalBase } from '#components';
|
||||||
import { render } from 'vue';
|
import { render } from 'vue';
|
||||||
|
|
||||||
|
|
||||||
const props = defineProps<{ links: string[] }>();
|
const props = defineProps<{ links: string[] }>();
|
||||||
|
|
||||||
function createModal(link: string) {
|
function createModal(link: string) {
|
||||||
|
@ -36,14 +34,14 @@ function createModal(link: string) {
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
.media-container {
|
.media-container {
|
||||||
display: flex;
|
grid-column: 2;
|
||||||
flex-wrap: wrap;
|
grid-row: 3;
|
||||||
gap: .2rem;
|
margin-left: .5dvw;
|
||||||
max-width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-item {
|
.media-item {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
max-width: 15dvw;
|
max-width: 15dvw;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<dialog ref="dialog" class="modal" :class="props.obscure ? 'modal-obscure' : 'modal-regular'">
|
<dialog ref="dialog" class="modal" :class="props.obscure ? 'modal-obscure' : 'modal-regular'">
|
||||||
<span class="modal-exit-button-container" style="position: absolute; right: 2em; top: .2em; width: .5em; height: .5em;">
|
<span class="modal-exit-button-container" style="position: absolute; right: 2em; top: .2em; width: .5em; height: .5em;">
|
||||||
<Button text="✕" variant="stealth" :callback="onCloseButton" />
|
<Button text="X" variant="neutral" :callback="() => dialog?.remove()" />
|
||||||
</span>
|
</span>
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<h1 class="modal-title">{{ title }}</h1>
|
<h1 class="modal-title">{{ title }}</h1>
|
||||||
|
@ -17,6 +17,8 @@ import Button from '~/components/UserInterface/Button.vue';
|
||||||
const props = defineProps<ModalProps>();
|
const props = defineProps<ModalProps>();
|
||||||
const dialog = ref<HTMLDialogElement>();
|
const dialog = ref<HTMLDialogElement>();
|
||||||
|
|
||||||
|
console.log("props:", props);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (dialog.value) {
|
if (dialog.value) {
|
||||||
dialog.value.showModal();
|
dialog.value.showModal();
|
||||||
|
@ -29,15 +31,6 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function onCloseButton () {
|
|
||||||
if (dialog.value) {
|
|
||||||
if (props.onCloseButton) {
|
|
||||||
props.onCloseButton()
|
|
||||||
}
|
|
||||||
|
|
||||||
dialog.value.remove
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -49,12 +42,9 @@ function onCloseButton () {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
opacity: 100%;
|
opacity: 100%;
|
||||||
|
padding: 1%;
|
||||||
padding: var(--standard-radius);
|
background-color: var(--sidebar-highlighted-background-color);
|
||||||
border-radius: var(--standard-radius);
|
|
||||||
background-color: var(--chat-highlighted-background-color);
|
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,7 @@ function copyInvite(type: "link" | "code") {
|
||||||
if (!invite.value) return;
|
if (!invite.value) return;
|
||||||
|
|
||||||
if (type == "link") {
|
if (type == "link") {
|
||||||
const runtimeConfig = useRuntimeConfig();
|
const inviteUrl = URL.parse(`invite/${invite.value}`, `${window.location.protocol}//${window.location.host}`);
|
||||||
const inviteUrl = URL.parse(`invite/${invite.value}`, `${window.location.protocol}//${window.location.host}${runtimeConfig.app.baseURL}`);
|
|
||||||
if (inviteUrl) {
|
if (inviteUrl) {
|
||||||
navigator.clipboard.writeText(inviteUrl.href);
|
navigator.clipboard.writeText(inviteUrl.href);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,256 +0,0 @@
|
||||||
<template>
|
|
||||||
<ModalBase :obscure="true" :onClose="props.onFinish" :onCloseButton="props.onFinish">
|
|
||||||
<div id="profile-container">
|
|
||||||
<div id="profile-header">
|
|
||||||
<div id="header-mask"></div>
|
|
||||||
<Avatar :profile="props.profile" id="avatar"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="profile-sub-header">
|
|
||||||
<div id="display-name">{{ displayName }}</div>
|
|
||||||
<div id="username-and-pronouns">
|
|
||||||
{{ username }}
|
|
||||||
<span v-if="pronouns">
|
|
||||||
•
|
|
||||||
{{ pronouns }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<!-- <div id="status">Status goes here lorem ipsum or something</div> -->
|
|
||||||
|
|
||||||
<div v-if="me.uuid != uuid" id="action-buttons-container">
|
|
||||||
<Button text="Message" variant="normal" :callback="buttonSendMessage"></Button>
|
|
||||||
<Button text="Friend" variant="neutral" :callback="buttonAddFriend"></Button>
|
|
||||||
</div>
|
|
||||||
<div v-else id="action-buttons-container">
|
|
||||||
<Button text="Edit Profile" variant="normal" :callback="buttonEditProfile"></Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<VerticalSpacer />
|
|
||||||
|
|
||||||
<div v-if="aboutMe" id="profile-body">
|
|
||||||
<div v-if="aboutMe" id="about-me-container">
|
|
||||||
<div><Icon name="lucide:info" size="1.1em"/></div>
|
|
||||||
<div id="about-me-text">
|
|
||||||
{{ " " + aboutMe }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<VerticalSpacer v-if="aboutMe" />
|
|
||||||
|
|
||||||
<div id="profile-footer">
|
|
||||||
<div id="dates">
|
|
||||||
<div v-if="registrationDate" class="date-entry">
|
|
||||||
<span class="date-entry-title">Registered at</span><br>
|
|
||||||
<span class="date-entry-value" :title="registrationDate.toLocaleTimeString()">{{ toDateString(registrationDate) }}</span>
|
|
||||||
</div>
|
|
||||||
<div v-if="joinDate" class="date-entry">
|
|
||||||
<span class="date-entry-title">Joined at</span><br>
|
|
||||||
<span class="date-entry-value" :title="joinDate.toLocaleTimeString()">{{ toDateString(joinDate) }}</span>
|
|
||||||
</div>
|
|
||||||
<div v-if="friendsSince" class="date-entry">
|
|
||||||
<span class="date-entry-title">Friends since</span><br>
|
|
||||||
<span class="date-entry-value" :title="friendsSince.toLocaleTimeString()">{{ toDateString(friendsSince) }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ModalBase>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import type { GuildMemberResponse, ModalProps, UserResponse } from '~/types/interfaces';
|
|
||||||
import VerticalSpacer from '../UserInterface/VerticalSpacer.vue';
|
|
||||||
import Button from '../UserInterface/Button.vue';
|
|
||||||
|
|
||||||
const { getDisplayName, getUsername, getPronouns, getAboutMe, getRegistrationDate, getGuildJoinDate, getFriendsSince, getUuid } = useProfile()
|
|
||||||
const { addFriend, fetchMe } = useApi();
|
|
||||||
|
|
||||||
const props = defineProps<ModalProps & {
|
|
||||||
profile: GuildMemberResponse,
|
|
||||||
onFinish: () => void
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const me = await fetchMe() as UserResponse
|
|
||||||
|
|
||||||
const displayName = getDisplayName(props.profile)
|
|
||||||
const username = getUsername(props.profile)
|
|
||||||
const pronouns = getPronouns(props.profile)
|
|
||||||
const aboutMe = getAboutMe(props.profile)
|
|
||||||
|
|
||||||
const registrationDate = getRegistrationDate(props.profile)
|
|
||||||
const joinDate = getGuildJoinDate(props.profile)
|
|
||||||
const friendsSince = await getFriendsSince(props.profile)
|
|
||||||
|
|
||||||
const uuid = getUuid(props.profile)
|
|
||||||
|
|
||||||
|
|
||||||
function toDateString(date: Date): string {
|
|
||||||
return date.toLocaleDateString(undefined, { day: '2-digit', month: 'short', year: 'numeric' })
|
|
||||||
}
|
|
||||||
|
|
||||||
function buttonSendMessage() {
|
|
||||||
navigateTo(`/me/${uuid}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function buttonAddFriend() {
|
|
||||||
try {
|
|
||||||
await addFriend(username)
|
|
||||||
alert("sent!")
|
|
||||||
} catch (error: any) {
|
|
||||||
if (error?.response?.status !== 200) {
|
|
||||||
alert(`error ${error?.response?.status} met whilst trying to add friend\n"${error?.response._data?.message}"`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function buttonEditProfile() {
|
|
||||||
navigateTo(`/settings#profile`)
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
#profile-container {
|
|
||||||
text-align: left;
|
|
||||||
|
|
||||||
position: relative;
|
|
||||||
max-height: 60dvh;
|
|
||||||
max-width: 60dvw;
|
|
||||||
height: 30em;
|
|
||||||
width: 40em;
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
background-color: var(--chat-background-color);
|
|
||||||
border-radius: var(--standard-radius);
|
|
||||||
|
|
||||||
overflow-y: scroll;
|
|
||||||
}
|
|
||||||
|
|
||||||
#profile-header {
|
|
||||||
flex-shrink: 0;
|
|
||||||
min-height: 9em;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#header-mask {
|
|
||||||
display: relative;
|
|
||||||
width: 100%;
|
|
||||||
min-height: 7em;
|
|
||||||
|
|
||||||
z-index: 0;
|
|
||||||
|
|
||||||
background-color: var(--primary-color);
|
|
||||||
border-radius: var(--standard-radius) var(--standard-radius) 0 0; /* top left and top right */
|
|
||||||
}
|
|
||||||
|
|
||||||
#avatar {
|
|
||||||
display: block;
|
|
||||||
position: absolute;
|
|
||||||
left: 2em;
|
|
||||||
top: 2.5em;
|
|
||||||
|
|
||||||
z-index: 1;
|
|
||||||
|
|
||||||
width: 6em;
|
|
||||||
height: 6em;
|
|
||||||
|
|
||||||
border: .15em solid var(--accent-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
#profile-sub-header {
|
|
||||||
margin-left: 1em;
|
|
||||||
margin-right: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#display-name {
|
|
||||||
font-weight: 800;
|
|
||||||
font-size: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#username-and-pronouns {
|
|
||||||
font-size: .9em;
|
|
||||||
color: var(--secondary-text-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
#status {
|
|
||||||
width: fit-content;
|
|
||||||
margin-top: .75em;
|
|
||||||
|
|
||||||
margin-left: -0.2em;
|
|
||||||
padding: .3em .5em;
|
|
||||||
|
|
||||||
background-color: var(--chatbox-background-color);
|
|
||||||
border-radius: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#action-buttons-container {
|
|
||||||
display: flex;
|
|
||||||
gap: .6em;
|
|
||||||
|
|
||||||
margin-top: .4em;
|
|
||||||
margin-bottom: .3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#profile-body {
|
|
||||||
margin-left: 1em;
|
|
||||||
margin-right: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#about-me-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
gap: .5em;
|
|
||||||
|
|
||||||
margin-top: .75em;
|
|
||||||
margin-bottom: .75em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#about-me-text {
|
|
||||||
display: inline;
|
|
||||||
margin-top: -0.5em;
|
|
||||||
|
|
||||||
align-self: center;
|
|
||||||
|
|
||||||
width: 100%;
|
|
||||||
font-size: .8em;
|
|
||||||
font-weight: lighter;
|
|
||||||
|
|
||||||
white-space: pre-line;
|
|
||||||
line-height: 1;
|
|
||||||
max-height: 7em; /* 7 x 1 */
|
|
||||||
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
scrollbar-width: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#about-me-text::-webkit-scrollbar {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#profile-footer {
|
|
||||||
margin-left: 1em;
|
|
||||||
margin-right: 1em;
|
|
||||||
padding-bottom: 5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#dates {
|
|
||||||
display: flex
|
|
||||||
}
|
|
||||||
|
|
||||||
.date-entry {
|
|
||||||
flex-grow: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.date-entry-title {
|
|
||||||
font-size: .8em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.date-entry-value {
|
|
||||||
font-size: 1em;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
<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,
|
||||||
|
|
|
@ -2,43 +2,18 @@
|
||||||
<div>
|
<div>
|
||||||
<h1>Appearance</h1>
|
<h1>Appearance</h1>
|
||||||
|
|
||||||
<h2>Themes</h2>
|
<p class="subtitle">THEMES</p>
|
||||||
<div class="themes">
|
<div class="themes">
|
||||||
<p class="subtitle">STYLES</p>
|
<div v-for="theme of themes" class="theme-preview-container">
|
||||||
<div class="styles">
|
<span class="theme-preview"
|
||||||
<div v-for="style of styles" class="theme-preview-container">
|
:title="theme.displayName"
|
||||||
<span class="theme-instance"
|
:style="{background:`linear-gradient(${theme.previewGradient})`}"
|
||||||
:title="style.displayName"
|
@click="changeTheme(theme.id, theme.themeUrl)"
|
||||||
@click="changeTheme(StyleLayout.Style, style)">
|
>
|
||||||
<div class="theme-content-container">
|
<span class="theme-title" :style="{color:`${theme.complementaryColor}`}">
|
||||||
<span class="style-background"
|
{{ theme.displayName }}
|
||||||
:style="{background:`linear-gradient(${style.previewGradient})`}"
|
|
||||||
></span>
|
|
||||||
<span class="theme-title" :style="{color:`${style.complementaryColor}`}">
|
|
||||||
{{ style.displayName }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</span>
|
||||||
</div>
|
|
||||||
<p class="subtitle">LAYOUTS</p>
|
|
||||||
<div class="layouts">
|
|
||||||
<div v-for="layout of layouts" class="theme-preview-container">
|
|
||||||
<div class="theme-instance"
|
|
||||||
:title="layout.displayName"
|
|
||||||
@click="changeTheme(StyleLayout.Layout, layout)">
|
|
||||||
<div class="theme-content-container">
|
|
||||||
<span class="layout-background"
|
|
||||||
:style="{backgroundImage:`url(${layout.previewImageUrl})`}"
|
|
||||||
></span>
|
|
||||||
<span class="theme-title" :style="{color:`${layout.complementaryColor}`}">
|
|
||||||
{{ layout.displayName }}
|
|
||||||
</span>
|
|
||||||
<!-- this breaks if it's a nuxtimg, i don't know why -->
|
|
||||||
<img class="layout-preview" :src="layout.previewImageUrl"></img>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -57,120 +32,51 @@
|
||||||
<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 { settingSave, settingsLoad } from '#imports';
|
import settingSave from '~/utils/settingSave';
|
||||||
|
|
||||||
const runtimeConfig = useRuntimeConfig()
|
const runtimeConfig = useRuntimeConfig()
|
||||||
|
const defaultThemes = runtimeConfig.public.defaultThemes
|
||||||
const baseURL = runtimeConfig.app.baseURL;
|
const baseURL = runtimeConfig.app.baseURL;
|
||||||
const styleFolder = `${baseURL}/themes/style`
|
|
||||||
const layoutFolder = `${baseURL}/themes/layout`
|
|
||||||
|
|
||||||
const timeFormatTextStrings = ["Auto", "12-Hour", "24-Hour"]
|
const timeFormatTextStrings = ["Auto", "12-Hour", "24-Hour"]
|
||||||
|
let themeLinkElement: HTMLLinkElement | null = null;
|
||||||
|
|
||||||
enum StyleLayout {
|
const themes: Array<Theme> = []
|
||||||
Style,
|
|
||||||
Layout
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Theme {
|
interface Theme {
|
||||||
|
id: string
|
||||||
displayName: string
|
displayName: string
|
||||||
|
previewGradient: string
|
||||||
complementaryColor: string
|
complementaryColor: string
|
||||||
cssData: string
|
|
||||||
themeUrl: string
|
themeUrl: string
|
||||||
previewGradient?: string
|
|
||||||
previewImageUrl?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function parseTheme(url: string): Promise<Theme | void> {
|
function changeTheme(id: string, url: string) {
|
||||||
const styleData: any = await $fetch(url)
|
if (themeLinkElement && themeLinkElement.getAttribute('href') === `${baseURL}themes/${url}`) {
|
||||||
|
return;
|
||||||
if (typeof styleData != "string") {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const metadataMatch = styleData.match(/\/\*([\s\S]*?)\*\//);
|
settingSave("selectedThemeId", id)
|
||||||
if (!metadataMatch) {
|
|
||||||
alert(`Failed to fetch metadata for a theme, panicking`)
|
// if the theme didn't originally load for some reason, create it
|
||||||
return
|
if (!themeLinkElement) {
|
||||||
|
themeLinkElement = document.createElement('link');
|
||||||
|
themeLinkElement.rel = 'stylesheet';
|
||||||
|
document.head.appendChild(themeLinkElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
const commentContent = metadataMatch[0].trim().split("\n");
|
themeLinkElement.href = `${baseURL}themes/${url}`;
|
||||||
const cssData = styleData.substring(metadataMatch[0].length).trim();
|
}
|
||||||
|
|
||||||
let displayName: string | undefined
|
async function fetchThemes() {
|
||||||
let complementaryColor: string | undefined
|
for (const theme of defaultThemes) {
|
||||||
let previewGradient: string | undefined
|
const themeConfig = await $fetch(`${baseURL}themes/${theme}.json`) as Theme
|
||||||
let previewImageUrl: string | undefined
|
themeConfig.id = theme
|
||||||
|
|
||||||
for (const line of commentContent) {
|
themes.push(themeConfig)
|
||||||
const lineArray = line.split("=")
|
|
||||||
if (lineArray.length === 2) {
|
|
||||||
switch (lineArray[0].trim()) {
|
|
||||||
case "displayName":
|
|
||||||
displayName = lineArray[1].trim()
|
|
||||||
break
|
|
||||||
case "complementaryColor":
|
|
||||||
complementaryColor = lineArray[1].trim()
|
|
||||||
break
|
|
||||||
case "previewGradient":
|
|
||||||
previewGradient = lineArray[1].trim()
|
|
||||||
break
|
|
||||||
case "previewImageUrl":
|
|
||||||
previewImageUrl = `${layoutFolder}/${lineArray[1].trim()}`
|
|
||||||
console.log(previewImageUrl)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(displayName, complementaryColor, previewGradient, previewImageUrl, cssData)
|
|
||||||
if (!(displayName && complementaryColor && cssData && (previewGradient || previewImageUrl))) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
displayName,
|
|
||||||
complementaryColor,
|
|
||||||
cssData,
|
|
||||||
themeUrl: url,
|
|
||||||
previewGradient,
|
|
||||||
previewImageUrl,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function parseThemeLayout(
|
await fetchThemes()
|
||||||
folder: string,
|
|
||||||
incomingThemeList: string[],
|
|
||||||
outputThemeList: Theme[]) {
|
|
||||||
for (const theme of incomingThemeList) {
|
|
||||||
const parsedThemeData = await parseTheme(`${folder}/${theme}`)
|
|
||||||
|
|
||||||
if (parsedThemeData) {
|
|
||||||
outputThemeList.push(parsedThemeData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const styles: Theme[] = [];
|
|
||||||
const layouts: Theme[] = [];
|
|
||||||
|
|
||||||
const styleList = await $fetch(`${styleFolder}/styles.json`)
|
|
||||||
const layoutList = await $fetch(`${layoutFolder}/layouts.json`)
|
|
||||||
|
|
||||||
if (Array.isArray(styleList)) {
|
|
||||||
await parseThemeLayout(styleFolder, styleList, styles)
|
|
||||||
}
|
|
||||||
if (Array.isArray(layoutList)) {
|
|
||||||
await parseThemeLayout(layoutFolder, layoutList, layouts)
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeTheme(themeType: StyleLayout, theme: Theme) {
|
|
||||||
if (themeType == StyleLayout.Style) {
|
|
||||||
settingSave("selectedThemeStyle", theme.themeUrl)
|
|
||||||
} else {
|
|
||||||
settingSave("selectedThemeLayout", theme.themeUrl)
|
|
||||||
}
|
|
||||||
loadPreferredThemes()
|
|
||||||
}
|
|
||||||
|
|
||||||
async function onTimeFormatClicked(index: number) {
|
async function onTimeFormatClicked(index: number) {
|
||||||
let format: "auto" | "12" | "24" = "auto"
|
let format: "auto" | "12" | "24" = "auto"
|
||||||
|
@ -190,89 +96,29 @@ async function onTimeFormatClicked(index: number) {
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.themes {
|
.themes {
|
||||||
--instance-size: 5em;
|
|
||||||
}
|
|
||||||
.styles, .layouts {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-preview-container {
|
.theme-preview-container {
|
||||||
margin: .5em;
|
margin: .5em;
|
||||||
width: var(--instance-size);
|
width: 5em;
|
||||||
height: var(--instance-size);
|
height: 5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-instance {
|
.theme-preview {
|
||||||
width: var(--instance-size);
|
width: 5em;
|
||||||
height: var(--instance-size);
|
height: 5em;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
border: .1em solid var(--primary-color);
|
border: .1em solid var(--primary-color);
|
||||||
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
text-align: center;
|
||||||
|
align-content: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-content-container {
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
text-align: center;
|
|
||||||
align-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.style-background, .layout-background {
|
|
||||||
position: absolute;
|
|
||||||
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
|
|
||||||
width: var(--instance-size);
|
|
||||||
height: var(--instance-size);
|
|
||||||
|
|
||||||
border-radius: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.layout-background {
|
|
||||||
background-size: cover;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
filter: brightness(35%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.layout-preview {
|
|
||||||
position: absolute;
|
|
||||||
pointer-events: none;
|
|
||||||
|
|
||||||
border: 0 solid var(--primary-color);
|
|
||||||
transform: translate(0, calc(var(--instance-size) / 2));
|
|
||||||
transition: all 250ms;
|
|
||||||
|
|
||||||
height: 0;
|
|
||||||
width: calc((height / 9) * 16);
|
|
||||||
max-height: 40dvh;
|
|
||||||
}
|
|
||||||
|
|
||||||
.theme-instance:hover .layout-preview {
|
|
||||||
border: .1em solid var(--primary-color);
|
|
||||||
filter: drop-shadow(0 0 .2em var(--secondary-color));
|
|
||||||
transform: translate(3.5em, -4em);
|
|
||||||
|
|
||||||
height: 40dvw;
|
|
||||||
}
|
|
||||||
|
|
||||||
.theme-title {
|
.theme-title {
|
||||||
position: absolute;
|
|
||||||
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
|
|
||||||
font-size: .8em;
|
font-size: .8em;
|
||||||
/* i CANNOT explain this line height calculation, but it works for a font size of .8em no matter what size the instances are */
|
line-height: 5em; /* same height as the parent to centre it vertically */
|
||||||
line-height: calc(var(--instance-size) * 1.25);
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -15,11 +15,8 @@
|
||||||
<label for="profile-pronouns-input" class="subtitle">PRONOUNS</label>
|
<label for="profile-pronouns-input" class="subtitle">PRONOUNS</label>
|
||||||
<input id="profile-pronouns-input" class="profile-data-input" type="text" v-model="user.pronouns" placeholder="Enter pronouns" />
|
<input id="profile-pronouns-input" class="profile-data-input" type="text" v-model="user.pronouns" placeholder="Enter pronouns" />
|
||||||
<label for="profile-about-me-input" class="subtitle">ABOUT ME</label>
|
<label for="profile-about-me-input" class="subtitle">ABOUT ME</label>
|
||||||
<div id="profile-about-me-input" class="profile-data-input profile-textarea-input"
|
<input id="profile-about-me-input" class="profile-data-input" type="text" v-model="user.about" placeholder="About me" />
|
||||||
placeholder="About Me" maxlength="240" wrap="soft" rows="8"
|
|
||||||
autocorrect="off" spellcheck="true" contenteditable="true"
|
|
||||||
@keyup="handleAboutMeKeyUp" ref="aboutMeInput">
|
|
||||||
</div>
|
|
||||||
<Button style="margin-top: 2dvh" text="Save Changes" :callback="saveChanges"></Button>
|
<Button style="margin-top: 2dvh" text="Save Changes" :callback="saveChanges"></Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -36,7 +33,6 @@
|
||||||
</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';
|
||||||
|
|
||||||
|
@ -45,8 +41,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 aboutMeInput = ref<HTMLDivElement>()
|
;
|
||||||
|
|
||||||
const { fetchUser } = useAuth();
|
const { fetchUser } = useAuth();
|
||||||
|
|
||||||
const user: UserResponse | undefined = await fetchUser()
|
const user: UserResponse | undefined = await fetchUser()
|
||||||
|
@ -129,12 +124,6 @@ function handleCrop(blob: Blob, url: string) {
|
||||||
function closeCropPopup() {
|
function closeCropPopup() {
|
||||||
isCropPopupVisible.value = false
|
isCropPopupVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAboutMeKeyUp(event: KeyboardEvent) {
|
|
||||||
if (user && aboutMeInput.value) {
|
|
||||||
user.about = aboutMeInput.value.innerText
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -149,9 +138,8 @@ function handleAboutMeKeyUp(event: KeyboardEvent) {
|
||||||
|
|
||||||
.profile-data-input {
|
.profile-data-input {
|
||||||
min-width: 30dvw;
|
min-width: 30dvw;
|
||||||
max-width: 30dvw;
|
|
||||||
margin: 0.07dvh;
|
margin: 0.07dvh;
|
||||||
padding: .1em .7em;
|
padding: 0.1dvh 0.7dvw;
|
||||||
height: 2.5em;
|
height: 2.5em;
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
@ -160,12 +148,6 @@ function handleAboutMeKeyUp(event: KeyboardEvent) {
|
||||||
background-color: var(--accent-color);
|
background-color: var(--accent-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.profile-textarea-input {
|
|
||||||
padding: .6em .7em;
|
|
||||||
|
|
||||||
height: fit-content;
|
|
||||||
}
|
|
||||||
|
|
||||||
#profile-popup {
|
#profile-popup {
|
||||||
margin-left: 2dvw;
|
margin-left: 2dvw;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<NuxtLink class="user-item" :href="`/me/${user.uuid}`" tabindex="0">
|
<NuxtLink class="user-item" :href="`/me/${user.uuid}`" tabindex="0">
|
||||||
<Avatar :profile="props.user" class="user-avatar"/>
|
<Avatar :user="props.user" class="user-avatar"/>
|
||||||
|
|
||||||
<span class="user-display-name" :style="`color: ${generateIrcColor(props.user.uuid)}`">
|
<span class="user-display-name">{{ getDisplayName(props.user) }}</span>
|
||||||
{{ getDisplayName(props.user) }}
|
|
||||||
</span>
|
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { UserResponse } from '~/types/interfaces';
|
import type { UserResponse } from '~/types/interfaces';
|
||||||
|
|
||||||
const { getDisplayName } = useProfile()
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
user: UserResponse
|
user: UserResponse
|
||||||
}>();
|
}>();
|
||||||
|
@ -38,15 +34,7 @@ const props = defineProps<{
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-avatar {
|
.user-avatar {
|
||||||
min-width: 2.3em;
|
width: 2.3em;
|
||||||
max-width: 2.3em;
|
height: 2.3em;
|
||||||
min-height: 2.3em;
|
|
||||||
max-height: 2.3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-display-name {
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="profile-popup">
|
<div id="profile-popup">
|
||||||
<Avatar :profile="props.user" id="avatar"/>
|
<Avatar :user="props.user" id="avatar"/>
|
||||||
|
|
||||||
<div id="cover-color"></div>
|
<div id="cover-color"></div>
|
||||||
<div id="main-body">
|
<div id="main-body">
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
<span v-if="props.user.pronouns"> - {{ props.user.pronouns }}</span>
|
<span v-if="props.user.pronouns"> - {{ props.user.pronouns }}</span>
|
||||||
</p>
|
</p>
|
||||||
<div id="about-me" v-if="props.user.about">
|
<div id="about-me" v-if="props.user.about">
|
||||||
{{ props.user.about.trim() }}
|
{{ props.user.about }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { UserResponse } from '~/types/interfaces';
|
import type { UserResponse } from '~/types/interfaces';
|
||||||
|
|
||||||
const { getDisplayName } = useProfile()
|
const { fetchMembers } = useApi();
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
user: UserResponse
|
user: UserResponse
|
||||||
|
@ -84,12 +84,5 @@ const props = defineProps<{
|
||||||
margin-top: 32px;
|
margin-top: 32px;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|
||||||
white-space: pre-line;
|
|
||||||
line-height: 1;
|
|
||||||
max-height: 7em; /* 7 x 1 */
|
|
||||||
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
|
@ -1,7 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<button class="button" :class="props.variant + '-button'"
|
<button @click="props.callback ? props.callback() : null" class="button" :class="props.variant + '-button'">
|
||||||
@click="props.callback ? props.callback() : null">
|
{{ props.text }}
|
||||||
{{ props.text }}
|
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -10,7 +9,7 @@
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
text: string,
|
text: string,
|
||||||
callback?: CallableFunction,
|
callback?: CallableFunction,
|
||||||
variant?: "normal" | "scary" | "neutral" | "stealth",
|
variant?: "normal" | "scary" | "neutral",
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -22,12 +21,11 @@ const props = defineProps<{
|
||||||
background-color: var(--primary-color);
|
background-color: var(--primary-color);
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
|
|
||||||
padding: 0.35em 0.65em;
|
padding: 0.4em 0.75em;
|
||||||
font-size: 1em;
|
font-size: 1.1em;
|
||||||
|
|
||||||
transition: background-color 0.2s;
|
transition: background-color 0.2s;
|
||||||
|
|
||||||
border-radius: var(--standard-radius);
|
border-radius: 0.7rem;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
||||||
|
@ -52,11 +50,4 @@ const props = defineProps<{
|
||||||
background-color: var(--accent-highlighted-color);
|
background-color: var(--accent-highlighted-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.stealth-button {
|
|
||||||
background-color: unset;
|
|
||||||
}
|
|
||||||
.stealth-button:hover {
|
|
||||||
background-color: unset;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
</style>
|
|
@ -1,30 +1,25 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="context-menu">
|
<div v-for="item of props.menuItems" class="context-menu-item" @click="runCallback(item)">
|
||||||
<button v-for="item of props.menuItems" class="context-menu-item"
|
{{ item.name }}
|
||||||
:class="'context-menu-item-' + item.type"
|
|
||||||
@click="runCallback(item)">
|
|
||||||
{{ item.name }} <Icon v-if="item.icon" :name="item.icon" />
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { ContextMenuInterface, ContextMenuItem } from '~/types/interfaces';
|
import type { ContextMenuItem } from '~/types/interfaces';
|
||||||
|
|
||||||
const props = defineProps<{ menuItems: ContextMenuItem[], pointerX: number, pointerY: number }>();
|
const props = defineProps<{ menuItems: ContextMenuItem[], cursorX: number, cursorY: number }>();
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const contextMenu = document.getElementById("context-menu");
|
const contextMenu = document.getElementById("context-menu");
|
||||||
if (contextMenu) {
|
if (contextMenu) {
|
||||||
contextMenu.style.left = props.pointerX.toString() + "px";
|
contextMenu.style.left = props.cursorX.toString() + "px";
|
||||||
contextMenu.style.top = props.pointerY.toString() + "px";
|
contextMenu.style.top = props.cursorY.toString() + "px";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function runCallback(item: ContextMenuItem) {
|
function runCallback(item: ContextMenuItem) {
|
||||||
const contextMenu = useState<ContextMenuInterface>("contextMenu");
|
removeContextMenu();
|
||||||
removeContextMenu(contextMenu);
|
|
||||||
item.callback();
|
item.callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,33 +31,14 @@ function runCallback(item: ContextMenuItem) {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 10rem;
|
width: 10dvw;
|
||||||
border: .1rem solid var(--reply-text-color);
|
border: .15rem solid cyan;
|
||||||
background-color: var(--sidebar-highlighted-background-color);
|
background-color: var(--background-color);
|
||||||
text-align: left;
|
text-align: center;
|
||||||
z-index: 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
.context-menu-item {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
height: 2rem;
|
|
||||||
width: 100%;
|
|
||||||
color: var(--text-color);
|
|
||||||
background-color: var(--popup-background-color);
|
|
||||||
border: none;
|
|
||||||
text-align: left;
|
|
||||||
padding-left: 1rem;
|
|
||||||
padding-right: 1rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.context-menu-item:hover {
|
.context-menu-item:hover {
|
||||||
background-color: var(--popup-highlighted-background-color);
|
background-color: rgb(50, 50, 50);
|
||||||
}
|
|
||||||
|
|
||||||
.context-menu-item-danger {
|
|
||||||
color: var(--danger-text-color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
|
@ -1,12 +0,0 @@
|
||||||
<template>
|
|
||||||
<span class="horizontal-spacer"></span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.spacer {
|
|
||||||
display: block;
|
|
||||||
min-width: 0.2dvh;
|
|
||||||
margin: 0.2dvh 0.8dvw;
|
|
||||||
background-color: var(--padding-color);
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -46,22 +46,11 @@ onMounted(async () => {
|
||||||
function scrollToReply(e: MouseEvent) {
|
function scrollToReply(e: MouseEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.log("clicked on reply box");
|
console.log("clicked on reply box");
|
||||||
let replyId: string;
|
const reply = document.querySelector(`.message[data-message-id="${props.replyId}"]`);
|
||||||
if (props.maxWidth == "reply") {
|
if (reply) {
|
||||||
replyId = props.replyId;
|
|
||||||
} else {
|
|
||||||
replyId = props.id;
|
|
||||||
}
|
|
||||||
const reply = document.querySelector(`.message[data-message-id="${replyId}"]`);
|
|
||||||
if (reply instanceof HTMLDivElement) {
|
|
||||||
console.log("reply:", reply);
|
console.log("reply:", reply);
|
||||||
console.log("scrolling into view");
|
console.log("scrolling into view");
|
||||||
reply.scrollIntoView({ behavior: "smooth", block: "center" });
|
reply.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||||
reply.style.transition = "background-color .3s";
|
|
||||||
reply.style.backgroundColor = "var(--chat-featured-message-color)";
|
|
||||||
setTimeout(() => {
|
|
||||||
reply.style.backgroundColor = "";
|
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,148 +0,0 @@
|
||||||
<template>
|
|
||||||
<div ref="resizableSidebar" class="resizable-sidebar"
|
|
||||||
:style="{
|
|
||||||
'width': storedWidth ? storedWidth : 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 { ContextMenuInterface, 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<string>();
|
|
||||||
|
|
||||||
const contextMenu = useState<ContextMenuInterface>("contextMenu");
|
|
||||||
|
|
||||||
const menuItems: ContextMenuItem[] = [
|
|
||||||
{ name: "Reset", type: "normal", callback: () => {
|
|
||||||
const defaultWidth = props.width ?? props.minWidth;
|
|
||||||
resizableSidebar.value!.style.width = defaultWidth;
|
|
||||||
if (props.localStorageName) {
|
|
||||||
localStorage.setItem(props.localStorageName, defaultWidth);
|
|
||||||
}
|
|
||||||
} }
|
|
||||||
]
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
loadStoredWidth();
|
|
||||||
|
|
||||||
if (resizableSidebar.value && widthResizer.value) {
|
|
||||||
widthResizer.value.addEventListener("pointerdown", (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
if (e.button == 2) {
|
|
||||||
showContextMenu(e, contextMenu.value, 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 = storedWidthValue;
|
|
||||||
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,11 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<span class="vertical-spacer"></span>
|
<span class="spacer"></span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.vertical-spacer {
|
.spacer {
|
||||||
|
height: 0.2dvh;
|
||||||
display: block;
|
display: block;
|
||||||
min-height: 0.2dvh;
|
|
||||||
margin: 0.8dvh 0.2dvw;
|
margin: 0.8dvh 0.2dvw;
|
||||||
background-color: var(--padding-color);
|
background-color: var(--padding-color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +1,24 @@
|
||||||
import type { ChannelResponse, GuildMemberResponse, GuildMembersResponse, 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[]> {
|
async function fetchGuilds(): Promise<GuildResponse[] | undefined> {
|
||||||
return ensureIsArray(await fetchWithApi(`/guilds`));
|
return 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 fetchMyGuilds(): Promise<GuildResponse[]> {
|
async function fetchChannels(guildId: string): Promise<ChannelResponse[] | undefined> {
|
||||||
return ensureIsArray(await fetchWithApi(`/me/guilds`));
|
return await fetchWithApi(`/guilds/${guildId}/channels`);
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchMe(): Promise<UserResponse | undefined> {
|
|
||||||
return await fetchWithApi("/me")
|
|
||||||
}
|
|
||||||
|
|
||||||
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, options?: { per_page?: number, page?: number }): Promise<GuildMembersResponse> {
|
async function fetchMembers(guildId: string): Promise<GuildMemberResponse[] | undefined> {
|
||||||
const query = new URLSearchParams();
|
return await fetchWithApi(`/guilds/${guildId}/members`);
|
||||||
query.set("page", options?.page ? options.page.toString() : "1");
|
|
||||||
if (options?.per_page) {
|
|
||||||
query.set("per_page", options.per_page.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("members query:", query);
|
|
||||||
return await fetchWithApi(`/guilds/${guildId}/members?${query.toString()}`) as GuildMembersResponse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchMember(guildId: string, memberId: string): Promise<GuildMemberResponse | undefined> {
|
async function fetchMember(guildId: string, memberId: string): Promise<GuildMemberResponse | undefined> {
|
||||||
|
@ -57,7 +34,12 @@ export const useApi = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchFriends(): Promise<UserResponse[]> {
|
async function fetchFriends(): Promise<UserResponse[]> {
|
||||||
return ensureIsArray(await fetchWithApi('/me/friends'));
|
const response = await fetchWithApi('/me/friends')
|
||||||
|
if (Array.isArray(response)) {
|
||||||
|
return response
|
||||||
|
} else {
|
||||||
|
return []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addFriend(username: string): Promise<void> {
|
async function addFriend(username: string): Promise<void> {
|
||||||
|
@ -105,15 +87,9 @@ export const useApi = () => {
|
||||||
await fetchWithApi("/auth/reset-password", { method: "POST", body: { password, token } });
|
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,
|
|
||||||
fetchMe,
|
|
||||||
fetchChannels,
|
fetchChannels,
|
||||||
fetchChannel,
|
fetchChannel,
|
||||||
fetchMembers,
|
fetchMembers,
|
||||||
|
@ -131,7 +107,6 @@ export const useApi = () => {
|
||||||
fetchInstanceStats,
|
fetchInstanceStats,
|
||||||
sendVerificationEmail,
|
sendVerificationEmail,
|
||||||
sendPasswordResetEmail,
|
sendPasswordResetEmail,
|
||||||
resetPassword,
|
resetPassword
|
||||||
fetchInvite
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,8 @@ export const useAuth = () => {
|
||||||
{
|
{
|
||||||
email, identifier: username, password: hashedPass, device_name: "Linux Laptop"
|
email, identifier: username, password: hashedPass, device_name: "Linux Laptop"
|
||||||
}
|
}
|
||||||
}) as { access_token: string, refresh_token: string };
|
});
|
||||||
//authStore.setAccessToken(accessToken);
|
//authStore.setAccessToken(accessToken);
|
||||||
accessToken.value = res.access_token;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function login(username: string, password: string, device_name: string) {
|
async function login(username: string, password: string, device_name: string) {
|
||||||
|
@ -31,9 +30,8 @@ export const useAuth = () => {
|
||||||
{
|
{
|
||||||
username, password: hashedPass, device_name: "Linux Laptop"
|
username, password: hashedPass, device_name: "Linux Laptop"
|
||||||
}
|
}
|
||||||
}) as { access_token: string, refresh_token: string };
|
});
|
||||||
console.log("hi");
|
console.log("hi");
|
||||||
accessToken.value = res.access_token;
|
|
||||||
console.log("access token:", accessToken.value);
|
console.log("access token:", accessToken.value);
|
||||||
//await fetchUser();
|
//await fetchUser();
|
||||||
}
|
}
|
||||||
|
@ -41,7 +39,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: "DELETE", credentials: "include" });
|
await fetchWithApi("/auth/logout", { method: "GET", credentials: "include" });
|
||||||
clearAuth();
|
clearAuth();
|
||||||
|
|
||||||
return await navigateTo("/login");
|
return await navigateTo("/login");
|
||||||
|
@ -67,8 +65,7 @@ export const useAuth = () => {
|
||||||
method: "POST"
|
method: "POST"
|
||||||
}) as any;
|
}) as any;
|
||||||
console.log("finished refreshing:", res);
|
console.log("finished refreshing:", res);
|
||||||
if (res && res.access_token) {
|
if (res) {
|
||||||
accessToken.value = res.access_token;
|
|
||||||
console.log("set new access token");
|
console.log("set new access token");
|
||||||
} else {
|
} else {
|
||||||
console.log("refresh didn't return access token");
|
console.log("refresh didn't return access token");
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
import type { GuildMemberResponse, UserResponse } from "~/types/interfaces"
|
|
||||||
|
|
||||||
const { fetchFriends } = useApi();
|
|
||||||
|
|
||||||
export const useProfile = () => {
|
|
||||||
function getAboutMe (profile: UserResponse | GuildMemberResponse): string | null {
|
|
||||||
if ("username" in profile) {
|
|
||||||
return profile.about
|
|
||||||
} else {
|
|
||||||
return profile.user.about
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDisplayName (profile: UserResponse | GuildMemberResponse): string {
|
|
||||||
if ("username" in profile) {
|
|
||||||
// assume it's a UserResponse
|
|
||||||
if (profile.display_name) return profile.display_name
|
|
||||||
return profile.username
|
|
||||||
} else {
|
|
||||||
// assume it's a GuildMemberResponse
|
|
||||||
if (profile.nickname) return profile.nickname
|
|
||||||
if (profile.user.display_name) return profile.user.display_name
|
|
||||||
return profile.user.username
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getFriendsSince (profile: UserResponse | GuildMemberResponse): Promise<Date | null> {
|
|
||||||
let user_uuid: string;
|
|
||||||
|
|
||||||
if ("username" in profile) {
|
|
||||||
user_uuid = profile.uuid
|
|
||||||
} else {
|
|
||||||
user_uuid = profile.user.uuid
|
|
||||||
}
|
|
||||||
|
|
||||||
const friends = await fetchFriends()
|
|
||||||
const friend = friends.find(friend => friend.uuid === user_uuid);
|
|
||||||
if (friend?.friends_since) {
|
|
||||||
return new Date(friend.friends_since);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
function getGuildJoinDate (profile: UserResponse | GuildMemberResponse): Date | null {
|
|
||||||
if ("username" in profile) {
|
|
||||||
return null
|
|
||||||
} else {
|
|
||||||
return uuidToDate(profile.uuid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPronouns (profile: UserResponse | GuildMemberResponse): string | null {
|
|
||||||
if ("username" in profile) {
|
|
||||||
return profile.pronouns
|
|
||||||
} else {
|
|
||||||
return profile.user.pronouns
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getRegistrationDate (profile: UserResponse | GuildMemberResponse): Date | null {
|
|
||||||
if ("username" in profile) {
|
|
||||||
return uuidToDate(profile.uuid)
|
|
||||||
} else {
|
|
||||||
return uuidToDate(profile.user.uuid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getUsername (profile: UserResponse | GuildMemberResponse): string {
|
|
||||||
if ("username" in profile) {
|
|
||||||
return profile.username
|
|
||||||
} else {
|
|
||||||
return profile.user.username
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getUuid (profile: UserResponse | GuildMemberResponse): string | null {
|
|
||||||
if ("username" in profile) {
|
|
||||||
return profile.uuid
|
|
||||||
} else {
|
|
||||||
return profile.user.uuid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
getAboutMe,
|
|
||||||
getDisplayName,
|
|
||||||
getFriendsSince,
|
|
||||||
getGuildJoinDate,
|
|
||||||
getRegistrationDate,
|
|
||||||
getPronouns,
|
|
||||||
getUsername,
|
|
||||||
getUuid
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,15 +17,19 @@
|
||||||
</div>
|
</div>
|
||||||
<VerticalSpacer />
|
<VerticalSpacer />
|
||||||
<div class="left-column-segment" id="left-column-middle">
|
<div class="left-column-segment" id="left-column-middle">
|
||||||
<NuxtLink v-for="guild of guilds" :href="`/servers/${guild.uuid}`" id="guild-icon-container">
|
<NuxtLink v-for="guild of guilds" :href="`/servers/${guild.uuid}`">
|
||||||
<NuxtImg v-if="guild.icon"
|
<NuxtImg v-if="guild.icon"
|
||||||
class="sidebar-icon guild-icon"
|
class="sidebar-icon guild-icon"
|
||||||
:alt="guild.name"
|
:alt="guild.name"
|
||||||
:src="guild.icon" />
|
:src="guild.icon" />
|
||||||
<DefaultIcon v-else
|
<NuxtImg v-else-if="!blockedCanvas"
|
||||||
class="sidebar-icon guild-icon"
|
class="sidebar-icon guild-icon"
|
||||||
:alt="guild.name"
|
:alt="guild.name"
|
||||||
:name="guild.name" :seed="guild.uuid"/>
|
: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>
|
</NuxtLink>
|
||||||
</div>
|
</div>
|
||||||
<VerticalSpacer />
|
<VerticalSpacer />
|
||||||
|
@ -48,24 +52,19 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ModalBase } from '#components';
|
import { ModalBase } from '#components';
|
||||||
import { render } from 'vue';
|
import { render } from 'vue';
|
||||||
import DefaultIcon from '~/components/DefaultIcon.vue';
|
|
||||||
import GuildDropdown from '~/components/Guild/GuildDropdown.vue';
|
import GuildDropdown from '~/components/Guild/GuildDropdown.vue';
|
||||||
import Loading from '~/components/Popups/Loading.vue';
|
|
||||||
import Button from '~/components/UserInterface/Button.vue';
|
import Button from '~/components/UserInterface/Button.vue';
|
||||||
import VerticalSpacer from '~/components/UserInterface/VerticalSpacer.vue';
|
import VerticalSpacer from '~/components/UserInterface/VerticalSpacer.vue';
|
||||||
import type { GuildResponse } from '~/types/interfaces';
|
import type { GuildResponse } from '~/types/interfaces';
|
||||||
|
|
||||||
definePageMeta({
|
|
||||||
keepalive: true
|
|
||||||
});
|
|
||||||
|
|
||||||
const loading = useState("loading", () => false);
|
const loading = useState("loading", () => false);
|
||||||
|
|
||||||
const createButtonContainer = ref<HTMLButtonElement>();
|
const createButtonContainer = ref<HTMLButtonElement>();
|
||||||
|
|
||||||
const { getDisplayName } = useProfile()
|
|
||||||
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!");
|
||||||
|
@ -96,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}`);
|
||||||
|
@ -152,7 +151,7 @@ const options = [
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const guilds = await api.fetchMyGuilds();
|
const guilds: GuildResponse[] | undefined = await fetchWithApi("/me/guilds");
|
||||||
|
|
||||||
function createDropdown() {
|
function createDropdown() {
|
||||||
const dropdown = h(GuildDropdown, { options });
|
const dropdown = h(GuildDropdown, { options });
|
||||||
|
@ -225,8 +224,6 @@ function createDropdown() {
|
||||||
|
|
||||||
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-segment {
|
.left-column-segment {
|
||||||
|
@ -246,12 +243,18 @@ function createDropdown() {
|
||||||
gap: var(--sidebar-icon-gap);
|
gap: var(--sidebar-icon-gap);
|
||||||
}
|
}
|
||||||
|
|
||||||
#home-button {
|
#middle-left-column {
|
||||||
height: var(--sidebar-icon-width);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
#guild-icon-container {
|
#home-button {
|
||||||
text-decoration: none;
|
height: var(--sidebar-icon-width);
|
||||||
}
|
}
|
||||||
|
|
||||||
.guild-icon {
|
.guild-icon {
|
||||||
|
|
|
@ -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[] = await fetchChannels(guildId);
|
const channels: ChannelResponse[] | undefined = await fetchChannels(guildId);
|
||||||
console.log("channels:", channels);
|
console.log("channels:", channels);
|
||||||
|
|
||||||
if (channels.length > 0) {
|
if (channels && 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 });
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,9 @@ export default defineNuxtConfig({
|
||||||
messageGroupingMaxDifference: 300000,
|
messageGroupingMaxDifference: 300000,
|
||||||
buildTimeString: new Date().toISOString(),
|
buildTimeString: new Date().toISOString(),
|
||||||
gitHash: process.env.GIT_SHORT_REV || "N/A",
|
gitHash: process.env.GIT_SHORT_REV || "N/A",
|
||||||
|
defaultThemes: [
|
||||||
|
"light", "ash", "dark", "rainbow-capitalism"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* nitro: {
|
/* nitro: {
|
||||||
|
|
|
@ -1,180 +0,0 @@
|
||||||
<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>
|
|
|
@ -1,33 +1,25 @@
|
||||||
<template>
|
<template>
|
||||||
<NuxtLayout name="client">
|
<NuxtLayout name="client">
|
||||||
<ResizableSidebar
|
<div id="middle-left-column" class="main-grid-row">
|
||||||
width="14rem" min-width="8rem" max-width="30rem"
|
<div id="server-name-container">
|
||||||
border-sides="right" local-storage-name="middleLeftColumn">
|
<span id="server-name">{{ server?.name }}</span>
|
||||||
<div id="middle-left-column" class="main-grid-row">
|
<button id="server-settings-button" @click="toggleGuildSettings">
|
||||||
<div id="server-name-container">
|
<Icon id="server-settings-icon" name="lucide:chevron-down" />
|
||||||
<span id="server-name" :title="server?.name">{{ server?.name }}</span>
|
</button>
|
||||||
<button id="server-settings-button" @click="toggleGuildSettings">
|
<GuildOptionsMenu v-if="showGuildSettings" />
|
||||||
<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>
|
||||||
</ResizableSidebar>
|
<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>
|
||||||
<MessageArea :channel-url="channelUrlPath" />
|
<MessageArea :channel-url="channelUrlPath" />
|
||||||
<ResizableSidebar
|
<div id="members-container">
|
||||||
width="14rem" min-width="5.5rem" max-width="30rem"
|
<div id="members-list">
|
||||||
border-sides="left" local-storage-name="membersListWidth">
|
<MemberEntry v-for="member of members" :member="member" tabindex="0"/>
|
||||||
<div id="members-container">
|
|
||||||
<div id="members-list">
|
|
||||||
<MemberEntry v-for="member of members" :member="member" tabindex="0"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</ResizableSidebar>
|
</div>
|
||||||
</NuxtLayout>
|
</NuxtLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -35,8 +27,7 @@
|
||||||
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/Guild/MemberEntry.vue";
|
import MemberEntry from "~/components/Guild/MemberEntry.vue";
|
||||||
import ResizableSidebar from "~/components/UserInterface/ResizableSidebar.vue";
|
import type { ChannelResponse, GuildMemberResponse, GuildResponse, MessageResponse } from "~/types/interfaces";
|
||||||
import type { ChannelResponse, GuildMemberResponse, GuildResponse } from "~/types/interfaces";
|
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
|
@ -62,23 +53,18 @@ 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() {
|
||||||
const membersRes = await fetchMembers(route.params.serverId as string);
|
members.value = await fetchMembers(route.params.serverId as string);
|
||||||
members.value = membersRes.objects;
|
|
||||||
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);
|
||||||
|
@ -101,7 +87,18 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +128,12 @@ function handleMemberClick(member: GuildMemberResponse) {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: .5em;
|
gap: .5em;
|
||||||
text-overflow: ellipsis;
|
}
|
||||||
|
|
||||||
|
.member-avatar {
|
||||||
|
height: 2.3em;
|
||||||
|
width: 2.3em;
|
||||||
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.member-display-name {
|
.member-display-name {
|
||||||
|
@ -149,8 +151,6 @@ 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 {
|
||||||
|
|
28
public/themes/ash.css
Normal file
28
public/themes/ash.css
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
:root {
|
||||||
|
--text-color: #f0e5e0;
|
||||||
|
--secondary-text-color: #e8e0db;
|
||||||
|
--reply-text-color: #969696;
|
||||||
|
|
||||||
|
--chat-background-color: #2f2e2d;
|
||||||
|
--chat-highlighted-background-color: #3f3b38;
|
||||||
|
--sidebar-background-color: #3e3a37;
|
||||||
|
--sidebar-highlighted-background-color: #46423b;
|
||||||
|
--topbar-background-color: #3a3733;
|
||||||
|
--chatbox-background-color: #3a3733;
|
||||||
|
|
||||||
|
--padding-color: #e0e0e0;
|
||||||
|
|
||||||
|
--primary-color: #f07028;
|
||||||
|
--primary-highlighted-color: #f28f4b;
|
||||||
|
--secondary-color: #683820;
|
||||||
|
--secondary-highlighted-color: #885830;
|
||||||
|
--accent-color: #a04b24;
|
||||||
|
--accent-highlighted-color: #b86038;
|
||||||
|
|
||||||
|
--sidebar-width: 2.5em;
|
||||||
|
--standard-radius: .5em;
|
||||||
|
--button-radius: .6em;
|
||||||
|
--guild-icon-radius: 20%;
|
||||||
|
--pfp-radius: 50%;
|
||||||
|
--preferred-font: Arial;
|
||||||
|
}
|
6
public/themes/ash.json
Normal file
6
public/themes/ash.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"displayName": "Ash",
|
||||||
|
"previewGradient": "45deg, #2f2e2d, #46423b",
|
||||||
|
"complementaryColor": "white",
|
||||||
|
"themeUrl": "ash.css"
|
||||||
|
}
|
31
public/themes/dark.css
Normal file
31
public/themes/dark.css
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
:root {
|
||||||
|
--text-color: #f7eee8;
|
||||||
|
--secondary-text-color: #f0e8e4;
|
||||||
|
--reply-text-color: #969696;
|
||||||
|
|
||||||
|
--chat-background-color: #1f1e1d;
|
||||||
|
--chat-highlighted-background-color: #2f2b28;
|
||||||
|
--sidebar-background-color: #2e2a27;
|
||||||
|
--sidebar-highlighted-background-color: #36322b;
|
||||||
|
--topbar-background-color: #2a2723;
|
||||||
|
--chatbox-background-color: #1a1713;
|
||||||
|
|
||||||
|
--padding-color: #484848;
|
||||||
|
|
||||||
|
--primary-color: #f4741f;
|
||||||
|
--primary-highlighted-color: #f68a3f;
|
||||||
|
--secondary-color: #7c4018;
|
||||||
|
--secondary-highlighted-color: #8f5b2c;
|
||||||
|
--accent-color: #b35719;
|
||||||
|
--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;
|
||||||
|
}
|
6
public/themes/dark.json
Normal file
6
public/themes/dark.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"displayName": "Dark",
|
||||||
|
"previewGradient": "45deg, #1f1e1d, #36322b",
|
||||||
|
"complementaryColor": "white",
|
||||||
|
"themeUrl": "dark.css"
|
||||||
|
}
|
|
@ -1,11 +1,4 @@
|
||||||
/*
|
|
||||||
displayName = Description
|
|
||||||
previewGradient = 45deg, #ff8f8f, #8f8fff
|
|
||||||
complementaryColor = black
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* this is not a real theme, but rather a template for themes */
|
/* this is not a real theme, but rather a template for themes */
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--text-color: #161518;
|
--text-color: #161518;
|
||||||
--secondary-text-color: #2b2930;
|
--secondary-text-color: #2b2930;
|
||||||
|
@ -13,12 +6,6 @@ complementaryColor = black
|
||||||
|
|
||||||
--chat-background-color: #80808000;
|
--chat-background-color: #80808000;
|
||||||
--chat-highlighted-background-color: #ffffff20;
|
--chat-highlighted-background-color: #ffffff20;
|
||||||
--chat-important-background-color: #ffc44f2f;
|
|
||||||
--chat-important-highlighted-background-color: #ffa45f4a;
|
|
||||||
--chat-featured-message-color: #4f2f1f58;
|
|
||||||
--popup-background-color: #2f1f1f;
|
|
||||||
--popup-highlighted-background-color: #3f2f2f;
|
|
||||||
|
|
||||||
--sidebar-background-color: #80808000;
|
--sidebar-background-color: #80808000;
|
||||||
--sidebar-highlighted-background-color: #ffffff20;
|
--sidebar-highlighted-background-color: #ffffff20;
|
||||||
--topbar-background-color: #80808000;
|
--topbar-background-color: #80808000;
|
||||||
|
@ -33,6 +20,12 @@ complementaryColor = black
|
||||||
--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 */
|
|
@ -1,18 +0,0 @@
|
||||||
/*
|
|
||||||
displayName = Gorb
|
|
||||||
previewImageUrl = gorb.jpg
|
|
||||||
complementaryColor = white
|
|
||||||
*/
|
|
||||||
|
|
||||||
:root {
|
|
||||||
--sidebar-icon-width: 2.5em;
|
|
||||||
--sidebar-icon-gap: .25em;
|
|
||||||
--sidebar-margin: .5em;
|
|
||||||
|
|
||||||
--minor-radius: .35em;
|
|
||||||
--standard-radius: .5em;
|
|
||||||
--button-radius: .6em;
|
|
||||||
--guild-icon-radius: 15%;
|
|
||||||
--pfp-radius: 50%;
|
|
||||||
--preferred-font: Arial;
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 187 KiB |
|
@ -1,3 +0,0 @@
|
||||||
[
|
|
||||||
"gorb.css"
|
|
||||||
]
|
|
|
@ -1,23 +1,10 @@
|
||||||
/*
|
|
||||||
displayName = Light
|
|
||||||
previewGradient = 45deg, #f0ebe8, #d4d0ca
|
|
||||||
complementaryColor = black
|
|
||||||
*/
|
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--text-color: #170f08;
|
--text-color: #170f08;
|
||||||
--secondary-text-color: #2f2b28;
|
--secondary-text-color: #2f2b28;
|
||||||
--reply-text-color: #969696;
|
--reply-text-color: #969696;
|
||||||
--danger-text-color: #ff0000;
|
|
||||||
|
|
||||||
--chat-background-color: #f0edeb;
|
|
||||||
--chat-highlighted-background-color: #aba8a4;
|
|
||||||
--chat-important-background-color: #df5f0b26;
|
|
||||||
--chat-important-hightlighted-background-color: #df5f0b3d;
|
|
||||||
--chat-featured-message-color: #e8ac841f;
|
|
||||||
--popup-background-color: #b8b4b0;
|
|
||||||
--popup-highlighted-background-color: #a6a4a2;
|
|
||||||
|
|
||||||
|
--chat-background-color: #f0ebe8;
|
||||||
|
--chat-highlighted-background-color: #e8e4e0;
|
||||||
--sidebar-background-color: #dbd8d4;
|
--sidebar-background-color: #dbd8d4;
|
||||||
--sidebar-highlighted-background-color: #d4d0ca;
|
--sidebar-highlighted-background-color: #d4d0ca;
|
||||||
--topbar-background-color: #dfdbd6;
|
--topbar-background-color: #dfdbd6;
|
||||||
|
@ -31,4 +18,10 @@ complementaryColor = black
|
||||||
--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;
|
||||||
}
|
}
|
6
public/themes/light.json
Normal file
6
public/themes/light.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"displayName": "Light",
|
||||||
|
"previewGradient": "45deg, #f0ebe8, #d4d0ca",
|
||||||
|
"complementaryColor": "black",
|
||||||
|
"themeUrl": "light.css"
|
||||||
|
}
|
|
@ -1,23 +1,10 @@
|
||||||
/*
|
|
||||||
displayName = Woke
|
|
||||||
previewGradient = 45deg, #ed2224, #ed2224, #f35b22, #f99621, #f5c11e, #f1eb1b 27%, #f1eb1b, #f1eb1b 33%, #63c720, #0c9b49, #21878d, #3954a5, #61379b, #93288e, #93288e
|
|
||||||
complementaryColor = white
|
|
||||||
*/
|
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--text-color: #000000;
|
--text-color: #161518;
|
||||||
--secondary-text-color: #1f1f1f;
|
--secondary-text-color: #2b2930;
|
||||||
--reply-text-color: #969696;
|
--reply-text-color: #969696;
|
||||||
--danger-text-color: #ff0000;
|
|
||||||
|
|
||||||
--chat-background-color: #b0b0b040;
|
--chat-background-color: #80808000;
|
||||||
--chat-highlighted-background-color: #ffffff20;
|
--chat-highlighted-background-color: #ffffff20;
|
||||||
--chat-important-background-color: #ff4f4f80;
|
|
||||||
--chat-important-highlighted-background-color: #ff6f6fa0;
|
|
||||||
--chat-featured-message-color: #4f8f4f80;
|
|
||||||
--popup-background-color: #80808080;
|
|
||||||
--popup-highlighted-background-color: #9f9f9f9f;
|
|
||||||
|
|
||||||
--sidebar-background-color: #80808000;
|
--sidebar-background-color: #80808000;
|
||||||
--sidebar-highlighted-background-color: #ffffff20;
|
--sidebar-highlighted-background-color: #ffffff20;
|
||||||
--topbar-background-color: #80808000;
|
--topbar-background-color: #80808000;
|
||||||
|
@ -32,6 +19,12 @@ complementaryColor = white
|
||||||
--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);
|
6
public/themes/rainbow-capitalism.json
Normal file
6
public/themes/rainbow-capitalism.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"displayName": "Woke",
|
||||||
|
"previewGradient": "45deg, #ed2224, #ed2224, #f35b22, #f99621, #f5c11e, #f1eb1b 27%, #f1eb1b, #f1eb1b 33%, #63c720, #0c9b49, #21878d, #3954a5, #61379b, #93288e, #93288e",
|
||||||
|
"complementaryColor": "white",
|
||||||
|
"themeUrl": "rainbow-capitalism.css"
|
||||||
|
}
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
displayName = Ash
|
|
||||||
previewGradient = 45deg, #2f2e2d, #46423b
|
|
||||||
complementaryColor = white
|
|
||||||
*/
|
|
||||||
|
|
||||||
:root {
|
|
||||||
--text-color: #f0e5e0;
|
|
||||||
--secondary-text-color: #e8e0db;
|
|
||||||
--reply-text-color: #969696;
|
|
||||||
--danger-text-color: #ff0000;
|
|
||||||
|
|
||||||
--chat-background-color: #383432;
|
|
||||||
--chat-highlighted-background-color: #4c4a48;
|
|
||||||
--chat-important-background-color: #ffcf5f38;
|
|
||||||
--chat-important-highlighted-background-color: #ffa86f4f;
|
|
||||||
--chat-featured-message-color: #4f3f2f60;
|
|
||||||
--popup-background-color: #2f2828;
|
|
||||||
--popup-highlighted-background-color: #382f2f;
|
|
||||||
|
|
||||||
--sidebar-background-color: #322f2d;
|
|
||||||
--sidebar-highlighted-background-color: #46423b;
|
|
||||||
--topbar-background-color: #3a3733;
|
|
||||||
--chatbox-background-color: #3a3733;
|
|
||||||
|
|
||||||
--padding-color: #4f4f4f;
|
|
||||||
|
|
||||||
--primary-color: #f07028;
|
|
||||||
--primary-highlighted-color: #f28f4b;
|
|
||||||
--secondary-color: #683820;
|
|
||||||
--secondary-highlighted-color: #885830;
|
|
||||||
--accent-color: #a04b24;
|
|
||||||
--accent-highlighted-color: #b86038;
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
displayName = Dark
|
|
||||||
previewGradient = 45deg, #1f1e1d, #36322b
|
|
||||||
complementaryColor = white
|
|
||||||
*/
|
|
||||||
|
|
||||||
:root {
|
|
||||||
--text-color: #f7eee8;
|
|
||||||
--secondary-text-color: #f0e8e4;
|
|
||||||
--reply-text-color: #969696;
|
|
||||||
--danger-text-color: #ff0000;
|
|
||||||
|
|
||||||
--chat-background-color: #282624;
|
|
||||||
--chat-highlighted-background-color: #383430;
|
|
||||||
--chat-important-background-color: #ffc44f2f;
|
|
||||||
--chat-important-highlighted-background-color: #ffa45f4a;
|
|
||||||
--chat-featured-message-color: #4f2f1f58;
|
|
||||||
--popup-background-color: #2f1f1f;
|
|
||||||
--popup-highlighted-background-color: #3f2f2f;
|
|
||||||
|
|
||||||
--sidebar-background-color: #1f1e1d;
|
|
||||||
--sidebar-highlighted-background-color: #2f2b28;
|
|
||||||
--topbar-background-color: #2a2723;
|
|
||||||
--chatbox-background-color: #1a1713;
|
|
||||||
|
|
||||||
--padding-color: #484848;
|
|
||||||
|
|
||||||
--primary-color: #f4741f;
|
|
||||||
--primary-highlighted-color: #f68a3f;
|
|
||||||
--secondary-color: #7c4018;
|
|
||||||
--secondary-highlighted-color: #8f5b2c;
|
|
||||||
--accent-color: #b35719;
|
|
||||||
--accent-highlighted-color: #c76a2e;
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
[
|
|
||||||
"ash.css",
|
|
||||||
"dark.css",
|
|
||||||
"light.css",
|
|
||||||
"rainbow-capitalism.css"
|
|
||||||
]
|
|
|
@ -1,11 +0,0 @@
|
||||||
export const enum Permission {
|
|
||||||
SendMessage = 1,
|
|
||||||
ManageChannel = 2,
|
|
||||||
ManageRole = 4,
|
|
||||||
CreateInvite = 8,
|
|
||||||
ManageInvite = 16,
|
|
||||||
ManageGuild = 32,
|
|
||||||
ManageMember = 64,
|
|
||||||
BanMember = 128,
|
|
||||||
KickMember = 256
|
|
||||||
}
|
|
|
@ -19,24 +19,16 @@ export interface GuildResponse {
|
||||||
description: string | null,
|
description: string | null,
|
||||||
icon: string | null,
|
icon: string | null,
|
||||||
owner_uuid: string,
|
owner_uuid: string,
|
||||||
roles: RoleResponse[],
|
roles: [],
|
||||||
member_count: number
|
member_count: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GuildMemberResponse {
|
export interface GuildMemberResponse {
|
||||||
uuid: string,
|
uuid: string,
|
||||||
nickname: string,
|
nickname: string,
|
||||||
|
user_uuid: string,
|
||||||
guild_uuid: string,
|
guild_uuid: string,
|
||||||
is_owner: boolean,
|
user: UserResponse
|
||||||
user: UserResponse,
|
|
||||||
roles: RoleResponse[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface GuildMembersResponse {
|
|
||||||
objects: GuildMemberResponse[],
|
|
||||||
amount: number,
|
|
||||||
pages: number,
|
|
||||||
page: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChannelResponse {
|
export interface ChannelResponse {
|
||||||
|
@ -53,7 +45,7 @@ export interface MessageResponse {
|
||||||
user_uuid: string,
|
user_uuid: string,
|
||||||
message: string,
|
message: string,
|
||||||
reply_to: string | null,
|
reply_to: string | null,
|
||||||
member: GuildMemberResponse,
|
user: UserResponse,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface InviteResponse {
|
export interface InviteResponse {
|
||||||
|
@ -104,20 +96,10 @@ export interface ModalProps {
|
||||||
title?: string,
|
title?: string,
|
||||||
obscure?: boolean,
|
obscure?: boolean,
|
||||||
onClose?: () => void,
|
onClose?: () => void,
|
||||||
onCancel?: () => void,
|
onCancel?: () => void
|
||||||
onCloseButton?: () => void,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContextMenuItem {
|
export interface ContextMenuItem {
|
||||||
name: string,
|
name: string,
|
||||||
icon?: string,
|
|
||||||
type: "normal" | "danger"
|
|
||||||
callback: (...args: any[]) => any;
|
callback: (...args: any[]) => any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContextMenuInterface {
|
|
||||||
show: boolean,
|
|
||||||
pointerX: number,
|
|
||||||
pointerY: number,
|
|
||||||
items: ContextMenuItem[]
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,9 +1,21 @@
|
||||||
import type { MessageResponse, UserResponse } from "./interfaces";
|
import type { MessageResponse, UserResponse } from "./interfaces";
|
||||||
|
|
||||||
export interface MessageProps {
|
export interface MessageProps {
|
||||||
message: MessageResponse,
|
class?: string,
|
||||||
replyMessage?: MessageResponse,
|
img?: string | null,
|
||||||
|
author: UserResponse
|
||||||
|
text: string,
|
||||||
|
timestamp: number,
|
||||||
|
format: "12" | "24",
|
||||||
type: "normal" | "grouped",
|
type: "normal" | "grouped",
|
||||||
|
marginBottom: boolean,
|
||||||
|
authorColor: string,
|
||||||
|
last: boolean,
|
||||||
|
messageId: string,
|
||||||
|
replyingTo?: boolean,
|
||||||
editing?: boolean,
|
editing?: boolean,
|
||||||
|
me: UserResponse
|
||||||
|
message: MessageResponse,
|
||||||
|
replyMessage?: MessageResponse
|
||||||
isMentioned?: boolean,
|
isMentioned?: boolean,
|
||||||
}
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
export interface ClientSettings {
|
export interface ClientSettings {
|
||||||
|
selectedThemeId?: string, // the ID of the theme, not the URL, for example "dark"
|
||||||
timeFormat?: TimeFormat
|
timeFormat?: TimeFormat
|
||||||
selectedThemeStyle?: string // URL
|
|
||||||
selectedThemeLayout?: string // URL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TimeFormat {
|
export interface TimeFormat {
|
||||||
|
|
17
utils/createContextMenu.ts
Normal file
17
utils/createContextMenu.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import { render } from "vue";
|
||||||
|
import ContextMenu from "~/components/UserInterface/ContextMenu.vue";
|
||||||
|
import type { ContextMenuItem } from "~/types/interfaces";
|
||||||
|
|
||||||
|
export default (e: MouseEvent, menuItems: ContextMenuItem[]) => {
|
||||||
|
console.log("Rendering new context menu");
|
||||||
|
const menuContainer = document.createElement("div");
|
||||||
|
menuContainer.id = "context-menu";
|
||||||
|
document.body.appendChild(menuContainer);
|
||||||
|
const contextMenu = h(ContextMenu, {
|
||||||
|
menuItems,
|
||||||
|
cursorX: e.clientX,
|
||||||
|
cursorY: e.clientY
|
||||||
|
});
|
||||||
|
render(contextMenu, menuContainer);
|
||||||
|
console.log("Rendered");
|
||||||
|
}
|
|
@ -1,12 +1,9 @@
|
||||||
import type { MessageProps } from "~/types/props";
|
import type { MessageProps } from "~/types/props";
|
||||||
|
|
||||||
const { fetchMe } = useApi()
|
|
||||||
|
|
||||||
export default async (element: HTMLDivElement, props: MessageProps) => {
|
export default async (element: HTMLDivElement, props: MessageProps) => {
|
||||||
console.log("message:", element);
|
console.log("message:", element);
|
||||||
const me = await fetchMe();
|
const me = await fetchWithApi("/me") as any;
|
||||||
|
if (props.author?.uuid == me.uuid) {
|
||||||
if (me && props.author?.uuid == me.uuid) {
|
|
||||||
const text = element.getElementsByClassName("message-text")[0] as HTMLDivElement;
|
const text = element.getElementsByClassName("message-text")[0] as HTMLDivElement;
|
||||||
text.contentEditable = "true";
|
text.contentEditable = "true";
|
||||||
text.focus();
|
text.focus();
|
||||||
|
|
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"
|
||||||
|
}
|
7
utils/getDisplayName.ts
Normal file
7
utils/getDisplayName.ts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import type { GuildMemberResponse, UserResponse } from "~/types/interfaces";
|
||||||
|
|
||||||
|
export function getDisplayName(user: UserResponse, member?: GuildMemberResponse): string {
|
||||||
|
if (member?.nickname) return member.nickname
|
||||||
|
if (user.display_name) return user.display_name
|
||||||
|
return user.username
|
||||||
|
}
|
|
@ -1,11 +0,0 @@
|
||||||
import type { Permission } from "~/types/enums";
|
|
||||||
import type { GuildMemberResponse } from "~/types/interfaces";
|
|
||||||
|
|
||||||
export default (member: GuildMemberResponse, permission: Permission) => {
|
|
||||||
for (const role of member.roles) {
|
|
||||||
if (role.permissions & permission) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
export default async (password: string) => {
|
export async function hashPassword(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;
|
||||||
|
}
|
|
@ -1,52 +0,0 @@
|
||||||
let styleLinkElement: HTMLLinkElement | null;
|
|
||||||
let layoutLinkElement: HTMLLinkElement | null;
|
|
||||||
|
|
||||||
|
|
||||||
export default () => {
|
|
||||||
const runtimeConfig = useRuntimeConfig()
|
|
||||||
const baseURL = runtimeConfig.app.baseURL;
|
|
||||||
|
|
||||||
let currentStyle = settingsLoad().selectedThemeStyle ?? undefined
|
|
||||||
let currentLayout = settingsLoad().selectedThemeLayout ?? `${baseURL}themes/layout/gorb.css`
|
|
||||||
|
|
||||||
if (!currentStyle) {
|
|
||||||
if (prefersLight()) {
|
|
||||||
currentStyle = `${baseURL}themes/style/light.css`
|
|
||||||
} else {
|
|
||||||
currentStyle = `${baseURL}themes/style/dark.css`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (styleLinkElement) {
|
|
||||||
styleLinkElement.href = currentStyle;
|
|
||||||
} else {
|
|
||||||
createStyleHead("style-theme", currentStyle)
|
|
||||||
styleLinkElement = document.getElementById('style-theme') as HTMLLinkElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (layoutLinkElement) {
|
|
||||||
layoutLinkElement.href = currentLayout;
|
|
||||||
} else {
|
|
||||||
createStyleHead("style-layout", currentLayout)
|
|
||||||
layoutLinkElement = document.getElementById('style-layout') as HTMLLinkElement;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// create a new theme link if one doesn't already exist
|
|
||||||
function createStyleHead(id: string, themeUrl: string) {
|
|
||||||
useHead({
|
|
||||||
link: [{
|
|
||||||
id: id,
|
|
||||||
rel: "stylesheet",
|
|
||||||
href: themeUrl
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function prefersLight(): boolean {
|
|
||||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
|
@ -1,12 +1,6 @@
|
||||||
import type { ContextMenuInterface } from "~/types/interfaces";
|
export default () => {
|
||||||
|
const contextMenu = document.getElementById("context-menu");
|
||||||
export default (contextMenu: Ref<ContextMenuInterface>) => {
|
if (contextMenu) {
|
||||||
console.log("resetting and hiding context menu");
|
contextMenu.remove();
|
||||||
contextMenu.value = {
|
|
||||||
show: false,
|
|
||||||
pointerX: 0,
|
|
||||||
pointerY: 0,
|
|
||||||
items: []
|
|
||||||
}
|
}
|
||||||
console.log("hidden context menu");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,19 +2,13 @@ import { render } from "vue";
|
||||||
import MessageReply from "~/components/UserInterface/MessageReply.vue";
|
import MessageReply from "~/components/UserInterface/MessageReply.vue";
|
||||||
import type { MessageProps } from "~/types/props";
|
import type { MessageProps } from "~/types/props";
|
||||||
|
|
||||||
const { getDisplayName } = useProfile()
|
|
||||||
|
|
||||||
export default (element: HTMLDivElement, props: MessageProps) => {
|
export default (element: HTMLDivElement, props: MessageProps) => {
|
||||||
console.log("element:", element);
|
console.log("element:", element);
|
||||||
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: getDisplayName(props.message.member), text: props.message.message || "", 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);
|
||||||
const message = document.querySelector(`.message[data-message-id='${props.message.uuid}']`);
|
|
||||||
if (message) {
|
|
||||||
message.classList.add("replying-to");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
import { render } from "vue";
|
|
||||||
import ContextMenu from "~/components/UserInterface/ContextMenu.vue";
|
|
||||||
import type { ContextMenuInterface, ContextMenuItem } from "~/types/interfaces";
|
|
||||||
|
|
||||||
export default (e: MouseEvent | PointerEvent, contextMenu: ContextMenuInterface, menuItems: ContextMenuItem[]) => {
|
|
||||||
console.log("Showing context menu");
|
|
||||||
contextMenu.show = true;
|
|
||||||
contextMenu.pointerX = e.clientX;
|
|
||||||
contextMenu.pointerY = e.clientY;
|
|
||||||
contextMenu.items = menuItems;
|
|
||||||
console.log("Showed");
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
import type { GuildMemberResponse } from "~/types/interfaces";
|
|
||||||
const { getDisplayName } = useProfile()
|
|
||||||
|
|
||||||
export default (members: GuildMemberResponse[]): GuildMemberResponse[] => {
|
|
||||||
return members.sort((a, b) => {
|
|
||||||
return getDisplayName(a).localeCompare(getDisplayName(b))
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
import type { UserResponse } from "~/types/interfaces";
|
|
||||||
const { getDisplayName } = useProfile()
|
|
||||||
|
|
||||||
export default (users: UserResponse[]): UserResponse[] => {
|
|
||||||
return users.sort((a, b) => {
|
|
||||||
return getDisplayName(a).localeCompare(getDisplayName(b))
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
export default (uuid: string): Date => {
|
|
||||||
const timeHex = uuid.substring(0, 8) + uuid.substring(9, 13);
|
|
||||||
const timestamp = parseInt(timeHex, 16);
|
|
||||||
|
|
||||||
return new Date(timestamp);
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
export default (username: string) => {
|
|
||||||
return /^[\w.-]+$/.test(username);
|
|
||||||
}
|
|
3
utils/validation.ts
Normal file
3
utils/validation.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export function validateUsername(username: string) {
|
||||||
|
return /^[\w.-]+$/.test(username);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue