Compare commits
14 commits
508af36704
...
59c9acdc9e
Author | SHA1 | Date | |
---|---|---|---|
59c9acdc9e | |||
3b1581d950 | |||
a324cc9300 | |||
a439f9481a | |||
379b85db4e | |||
751bdcfd9a | |||
a5f0e19716 | |||
7ad2b6f299 | |||
6548f9329e | |||
e6bff0042d | |||
585e79dac6 | |||
93b7bf9154 | |||
19fcccfb5b | |||
9981bc4158 |
10 changed files with 197 additions and 157 deletions
4
app.vue
4
app.vue
|
@ -1,14 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<Loading v-if="loading" />
|
|
||||||
<NuxtPage />
|
<NuxtPage />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|
||||||
const loading = useState("loading");
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -18,7 +15,6 @@ body {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
color: rgb(190, 190, 190);
|
color: rgb(190, 190, 190);
|
||||||
background-color: rgb(30, 30, 30);
|
background-color: rgb(30, 30, 30);
|
||||||
height: 100%;
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="message-area">
|
<div id="message-area">
|
||||||
<div id="messages">
|
<div id="messages" ref="messagesElement">
|
||||||
<Message v-for="message of messages" :username="displayNames[message.user_uuid]" :text="message.message"
|
<Message v-for="message of messages" :username="displayNames[message.user_uuid]" :text="message.message"
|
||||||
:timestamp="uuidToTimestamp(message.uuid)" format="12" />
|
:timestamp="uuidToTimestamp(message.uuid)" format="12" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -29,7 +29,7 @@ if (messagesRes && props.reverse) {
|
||||||
messagesRes.reverse();
|
messagesRes.reverse();
|
||||||
}
|
}
|
||||||
|
|
||||||
const messages = ref(messagesRes ?? []);
|
const messages = ref<MessageResponse[]>([]);
|
||||||
|
|
||||||
const displayNames = ref<Record<string, string>>({});
|
const displayNames = ref<Record<string, string>>({});
|
||||||
|
|
||||||
|
@ -37,6 +37,18 @@ const route = useRoute();
|
||||||
|
|
||||||
const messageInput = ref<string>();
|
const messageInput = ref<string>();
|
||||||
|
|
||||||
|
const messagesElement = ref<HTMLDivElement>();
|
||||||
|
|
||||||
|
if (messagesRes) messages.value = messagesRes;
|
||||||
|
const displayNamesArr: Record<string, string> = {};
|
||||||
|
for (const message of messages.value) {
|
||||||
|
if (!displayNamesArr[message.user_uuid]) {
|
||||||
|
const displayName = await getDisplayName(message.user_uuid);
|
||||||
|
displayNamesArr[message.user_uuid] = displayName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
displayNames.value = displayNamesArr;
|
||||||
|
|
||||||
const accessToken = useCookie("access_token").value;
|
const accessToken = useCookie("access_token").value;
|
||||||
const apiBase = useCookie("api_base").value;
|
const apiBase = useCookie("api_base").value;
|
||||||
const { refresh } = useAuth();
|
const { refresh } = useAuth();
|
||||||
|
@ -88,14 +100,7 @@ function sendMessage(e: Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const displayNamesArr: Record<string, string> = {};
|
messagesElement.value?.scrollTo({ top: messagesElement.value.scrollHeight });
|
||||||
for (const message of messages.value) {
|
|
||||||
if (!displayNamesArr[message.user_uuid]) {
|
|
||||||
const displayName = await getDisplayName(message.user_uuid);
|
|
||||||
displayNamesArr[message.user_uuid] = displayName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
displayNames.value = displayNamesArr;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -117,17 +122,9 @@ onMounted(async () => {
|
||||||
|
|
||||||
#message-box {
|
#message-box {
|
||||||
border: 1px solid rgb(70, 70, 70);
|
border: 1px solid rgb(70, 70, 70);
|
||||||
|
padding-bottom: 1dvh;
|
||||||
|
padding-top: 1dvh;
|
||||||
margin-bottom: 1dvh;
|
margin-bottom: 1dvh;
|
||||||
height: 7%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#message-form {
|
|
||||||
height: 50%;
|
|
||||||
width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#message-input {
|
#message-input {
|
||||||
|
|
|
@ -64,8 +64,12 @@ export const useAuth = () => {
|
||||||
method: "POST"
|
method: "POST"
|
||||||
}) as any;
|
}) as any;
|
||||||
console.log("finished refreshing:", res);
|
console.log("finished refreshing:", res);
|
||||||
accessToken.value = res?.access_token;
|
if (res.access_token) {
|
||||||
|
accessToken.value = res.access_token;
|
||||||
console.log("set new access token");
|
console.log("set new access token");
|
||||||
|
} else {
|
||||||
|
console.log("refresh didn't return access token");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchUser() {
|
async function fetchUser() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<Loading v-if="!mounted" />
|
<NuxtLayout>
|
||||||
<div v-else id="root-container" style="margin-top: 5dvh;">
|
<div id="root-container" style="margin-top: 5dvh;">
|
||||||
<div id="main-container">
|
<div id="main-container">
|
||||||
<div v-if="!instanceUrl">
|
<div v-if="!instanceUrl">
|
||||||
<div v-if="instanceError" style="color: red;">
|
<div v-if="instanceError" style="color: red;">
|
||||||
|
@ -44,12 +44,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</NuxtLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { FetchError } from 'ofetch';
|
import { FetchError } from 'ofetch';
|
||||||
|
|
||||||
const mounted = ref(false);
|
|
||||||
const redirectTo = useRoute().query.redirect_to;
|
const redirectTo = useRoute().query.redirect_to;
|
||||||
|
|
||||||
const apiVersion = useRuntimeConfig().public.apiVersion;
|
const apiVersion = useRuntimeConfig().public.apiVersion;
|
||||||
|
@ -64,7 +64,6 @@ if (auth.accessToken.value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
mounted.value = true;
|
|
||||||
const cookie = useCookie("instance_url").value;
|
const cookie = useCookie("instance_url").value;
|
||||||
instanceUrl.value = cookie;
|
instanceUrl.value = cookie;
|
||||||
console.log(cookie);
|
console.log(cookie);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="client-root">
|
<Loading v-show="loading" />
|
||||||
|
<div :class="{ hidden: loading, visible: !loading }" id="client-root">
|
||||||
<div id="homebar">
|
<div id="homebar">
|
||||||
<div class="homebar-item">
|
<div class="homebar-item">
|
||||||
main bar
|
main bar
|
||||||
|
@ -21,6 +22,8 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|
||||||
|
const loading = useState("loading", () => false);
|
||||||
|
|
||||||
const servers = [
|
const servers = [
|
||||||
{
|
{
|
||||||
name: "Test",
|
name: "Test",
|
||||||
|
@ -90,11 +93,21 @@ function sendMessage(e: Event) {
|
||||||
<style>
|
<style>
|
||||||
#client-root {
|
#client-root {
|
||||||
/* border: 1px solid white; */
|
/* border: 1px solid white; */
|
||||||
height: 100%;
|
height: 100dvh;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 4fr 18fr 4fr;
|
grid-template-columns: 1fr 4fr 18fr 4fr;
|
||||||
grid-template-rows: 4dvh auto;
|
grid-template-rows: 4dvh auto;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
opacity: 0%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.visible {
|
||||||
|
opacity: 100%;
|
||||||
|
transition-duration: 500ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
#homebar {
|
#homebar {
|
||||||
|
@ -114,7 +127,6 @@ function sendMessage(e: Event) {
|
||||||
#__nuxt {
|
#__nuxt {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: column;
|
flex-flow: column;
|
||||||
height: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid-column {
|
.grid-column {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
export default defineNuxtRouteMiddleware(async (to, from) => {
|
export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||||
console.log("to.path:", to.path);
|
console.log("to.path:", to.path);
|
||||||
|
const loading = useState("loading");
|
||||||
const accessToken = useCookie("access_token").value;
|
const accessToken = useCookie("access_token").value;
|
||||||
if (["/login", "/register"].includes(to.path)) {
|
if (["/login", "/register"].includes(to.path)) {
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
|
@ -9,9 +10,15 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!accessToken) {
|
if (!accessToken) {
|
||||||
|
loading.value = true;
|
||||||
|
console.log("set loading to true");
|
||||||
const { refresh } = useAuth();
|
const { refresh } = useAuth();
|
||||||
console.log("hi");
|
console.log("hi");
|
||||||
await refresh();
|
await refresh();
|
||||||
return await navigateTo("/login");
|
const query = new URLSearchParams();
|
||||||
|
query.set("redirect_to", to.path);
|
||||||
|
loading.value = false;
|
||||||
|
console.log("set loading to false");
|
||||||
|
return await navigateTo("/login" + (query ?? ""));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,7 +10,19 @@ export default defineNuxtConfig({
|
||||||
E.g.: baseURL set to "/web" would host at https://gorb.app/web
|
E.g.: baseURL set to "/web" would host at https://gorb.app/web
|
||||||
Default is "/" (aka root), which hosts at https://gorb.app/
|
Default is "/" (aka root), which hosts at https://gorb.app/
|
||||||
*/
|
*/
|
||||||
baseURL: "/web"
|
baseURL: "/",
|
||||||
|
head: {
|
||||||
|
title: 'Gorb',
|
||||||
|
// this is purely used to embed in that other chat app, and similar stuff
|
||||||
|
meta: [
|
||||||
|
{ property: 'og:title', content: 'Gorb' },
|
||||||
|
{ property: 'og:description', content: 'Gorb is an open-source (and eventually federated) chat platform where you can join and chat in servers, chat privately in DMs, and more.' },
|
||||||
|
{ property: 'og:url', content: 'https://gorb.app/web' },
|
||||||
|
{ property: 'og:type', content: 'website' },
|
||||||
|
{ property: 'og:site_name', content: 'Gorb' },
|
||||||
|
{ property: 'theme-color', content: "#df5f0b" }
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
runtimeConfig: {
|
runtimeConfig: {
|
||||||
public: {
|
public: {
|
||||||
|
|
|
@ -39,25 +39,20 @@
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
const server: GuildResponse | undefined = await fetchWithApi(`servers/${route.params.serverId}`);
|
const loading = useState("loading");
|
||||||
|
|
||||||
const channels: ChannelResponse[] | undefined = await fetchWithApi(
|
|
||||||
`servers/${route.params.serverId}/channels`
|
|
||||||
);
|
|
||||||
const channel: ChannelResponse | undefined = await fetchWithApi(
|
|
||||||
route.path
|
|
||||||
);
|
|
||||||
|
|
||||||
const channelUrlPath = `servers/${route.params.serverId}/channels/${route.params.channelId}`;
|
const channelUrlPath = `servers/${route.params.serverId}/channels/${route.params.channelId}`;
|
||||||
|
|
||||||
console.log("channel:", channel);
|
const server = ref<GuildResponse | undefined>();
|
||||||
|
const channels = ref<ChannelResponse[] | undefined>();
|
||||||
|
const channel = ref<ChannelResponse | undefined>();
|
||||||
|
|
||||||
const showInvitePopup = ref(false);
|
const showInvitePopup = ref(false);
|
||||||
|
|
||||||
import type { ChannelResponse, GuildResponse, MessageResponse } from "~/types/interfaces";
|
import type { ChannelResponse, GuildResponse, MessageResponse } from "~/types/interfaces";
|
||||||
|
|
||||||
//const servers = await fetchWithApi("/servers") as { uuid: string, name: string, description: string }[];
|
//const servers = await fetchWithApi("/servers") as { uuid: string, name: string, description: string }[];
|
||||||
//console.log("servers:", servers);
|
//console.log("channelid: servers:", servers);
|
||||||
const members = [
|
const members = [
|
||||||
{
|
{
|
||||||
id: "3287484395",
|
id: "3287484395",
|
||||||
|
@ -106,6 +101,24 @@ const members = [
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
loading.value = true;
|
||||||
|
console.log("channelid: set loading to true");
|
||||||
|
server.value = await fetchWithApi(`servers/${route.params.serverId}`);
|
||||||
|
|
||||||
|
channels.value = await fetchWithApi(
|
||||||
|
`servers/${route.params.serverId}/channels`
|
||||||
|
);
|
||||||
|
channel.value = await fetchWithApi(
|
||||||
|
route.path
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log("channelid: channel:", channel);
|
||||||
|
await sleep(3000);
|
||||||
|
loading.value = false;
|
||||||
|
console.log("channelid: set loading to false");
|
||||||
|
});
|
||||||
|
|
||||||
function showServerSettings() { }
|
function showServerSettings() { }
|
||||||
|
|
||||||
function toggleInvitePopup(e: Event) {
|
function toggleInvitePopup(e: Event) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue