diff --git a/src/components/chat/ChatList.vue b/src/components/chat/ChatList.vue new file mode 100644 index 0000000..381b91b --- /dev/null +++ b/src/components/chat/ChatList.vue @@ -0,0 +1,21 @@ + + + \ No newline at end of file diff --git a/src/components/chat/ChatMessage.vue b/src/components/chat/ChatMessage.vue new file mode 100644 index 0000000..a3fdeb4 --- /dev/null +++ b/src/components/chat/ChatMessage.vue @@ -0,0 +1,27 @@ + + + + + diff --git a/src/components/posts/PostAttachment.vue b/src/components/posts/PostAttachment.vue index d8fb8b3..65f06cc 100644 --- a/src/components/posts/PostAttachment.vue +++ b/src/components/posts/PostAttachment.vue @@ -16,7 +16,7 @@ v-if="item.type === 1" loading="lazy" decoding="async" - class="cursor-zoom-in content-visibility-auto" + class="cursor-zoom-in content-visibility-auto w-full h-full object-contain" :src="getUrl(item)" :alt="item.filename" @click="openLightbox(item, idx)" diff --git a/src/views/chat/channel.vue b/src/layouts/chat.vue similarity index 64% rename from src/views/chat/channel.vue rename to src/layouts/chat.vue index ccc6e05..24b00cb 100644 --- a/src/views/chat/channel.vue +++ b/src/layouts/chat.vue @@ -3,12 +3,14 @@
-

{{ metadata?.name }}

+

{{ channels.current?.name }}

-

{{ metadata?.description }}

+

{{ channels.current?.description }}

+ + Something went wrong... {{ error }} @@ -16,15 +18,15 @@ \ No newline at end of file diff --git a/src/router/index.ts b/src/router/index.ts index ed9e3de..fd25488 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -38,12 +38,13 @@ const router = createRouter({ }, { - path: "/chat", + path: "/chat/:channel", + component: () => import("@/layouts/chat.vue"), children: [ { - path: ":channel", + path: "", name: "chat.channel", - component: () => import("@/views/chat/channel.vue") + component: () => import("@/views/chat/page.vue"), } ] }, diff --git a/src/stores/channels.ts b/src/stores/channels.ts new file mode 100644 index 0000000..bb75010 --- /dev/null +++ b/src/stores/channels.ts @@ -0,0 +1,37 @@ +import { defineStore } from "pinia" +import { reactive, ref } from "vue" +import { checkLoggedIn, getAtk } from "@/stores/userinfo" +import { request } from "@/scripts/request" + +export const useChannels = defineStore("channels", () => { + const done = ref(false) + + const show = reactive({ + editor: false, + delete: false + }) + + const related_to = reactive<{ edit_to: any; delete_to: any }>({ + edit_to: null, + delete_to: null + }) + + const available = ref([]) + const current = ref(null) + const messages = ref([]) + + async function list() { + if (!(await checkLoggedIn())) return + + const res = await request("messaging", "/api/channels/me/available", { + headers: { Authorization: `Bearer ${await getAtk()}` } + }) + if (res.status !== 200) { + throw new Error(await res.text()) + } else { + available.value = await res.json() + } + } + + return { done, show, related_to, available, current, messages, list } +}) \ No newline at end of file diff --git a/src/stores/realms.ts b/src/stores/realms.ts index ab13adf..d4f4855 100644 --- a/src/stores/realms.ts +++ b/src/stores/realms.ts @@ -31,7 +31,5 @@ export const useRealms = defineStore("realms", () => { } } - list().then(() => console.log("[STARTUP HOOK] Fetch available realm successes.")) - return { done, show, related: related_to, available, list } }) diff --git a/src/stores/userinfo.ts b/src/stores/userinfo.ts index 8849bad..d6f9dc1 100644 --- a/src/stores/userinfo.ts +++ b/src/stores/userinfo.ts @@ -2,6 +2,8 @@ import { defineStore } from "pinia" import { ref } from "vue" import { request } from "@/scripts/request" import { Preferences } from "@capacitor/preferences" +import { useRealms } from "@/stores/realms" +import { useChannels } from "@/stores/channels" export interface Userinfo { isReady: boolean @@ -30,6 +32,10 @@ export async function checkLoggedIn(): Promise { } export const useUserinfo = defineStore("userinfo", () => { + const userinfoHooks = { + after: [useRealms().list, useChannels().list] + } + const userinfo = ref(defaultUserinfo) const isReady = ref(false) @@ -54,6 +60,8 @@ export const useUserinfo = defineStore("userinfo", () => { displayName: data["nick"], data: data } + + userinfoHooks.after.forEach((call) => call()) } return { userinfo, isReady, readProfiles } diff --git a/src/views/chat/page.vue b/src/views/chat/page.vue new file mode 100644 index 0000000..c102c63 --- /dev/null +++ b/src/views/chat/page.vue @@ -0,0 +1,85 @@ + + + \ No newline at end of file